Home  >  Article  >  php教程  >  tp中使用验证码验证 - 晨曦年华

tp中使用验证码验证 - 晨曦年华

WBOY
WBOYOriginal
2016-05-20 13:15:171245browse

    namespace   Admin\Controller;

    use  Think\Controller;

    use  Think\Verify;

   class  LoginController extends Controller{

          public  function Login(){

                 if(!empty($_POST)){

                        $vry = new Verfiy();

                       if($vry->check($_POST['capchat'])){

                               echo  “验证码正确”; 

                      }

                }

          }

           public function verfiyImage(){

                   //验证码配置

                   $config = array(

                        'imageH'  => 45,  //验证码的图片高度

                       'imageW'   =>100, //验证码的图片宽度

                        'fontSize'  => 15,  //验证码的字体大小

                        'length'     =>4,    //验证码的长度

                        'fontttf'     => '2.ttf',    //验证码的字体

         }

         //实例化verify类

         $very = new Verfiy($config);

         //输出验证码

         $very -> entry();//输出验证码

   } 

  在login.html页面中

  tp中使用验证码验证 - 晨曦年华

   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn