thinkphp系统自带验证码

        <div class="verify_code cf g-hidden" id="J-actionupload-sheet-verifyCode">

		  <dl class="cf">

            <dt>验证码<span>*</span></dt>

            <dd><input class="textinput" name="verify_code" type="text" required><img alt="点击切换" src="{:U('verify')}"><a title="换一张" href="javascript:;">换一张</a></dd>

          </dl>

          <p class="g-validator-msg" data-validator-target="verify_code" data-validator-msg="请输入验证码"></p>

        </div>

  验证方法:

    public function verify(){

    	$config =	array(

    			'fontSize'  =>  16,              // 验证码字体大小(px)

    			'useNoise'=>false,

    			'useCurve'=>false

    			 

    	);

    	$verify = new \Think\Verify($config);

    	$verify->entry(1);

    }

  

        if(!$this->check_verify(trim(I('post.verify_code')))){

            $json['rst']='9';

            $this->ajaxReturn($json);

        }



    function check_verify($code, $id = 1){

        $verify = new \Think\Verify();

        return $verify->check($code, $id);

    }

 

 

 

你可能感兴趣的:(thinkphp)