thinkphp后台登陆ajax提交验证码怎么进行判断

2025年03月23日 01:26
有3个网友回答
网友(1):

  1. 判断传过去的验证码和cookie里的验证码让否一致

    具体代码如下:



 protected function
check_verify($code) //验证函数
{
$verify = new
\Think\Verify();
return $verify->check($code);
}
Public function login(){ //登陆
$authcode = trim(I('authcode'));
//获取前端ajax传过来的authcode

if ( (
!$this->check_verify($authcode)) ){
$this->ajaxReturn(0,"验证码错误",0);

}

网友(2):

protected function check_verify($code) //验证函数,3.2.3版本
{
$verify = new \Think\Verify();
return $verify->check($code);
}
Public function dologin(){ //登陆
$authcode = trim(I('authcode')); //获取前端ajax传过来的authcode
//下面的代码是3.2.3验证
if ( ( !$this->check_verify($authcode)) ){
$this->ajaxReturn(0,"验证码错误",0);
}

网友(3):

就是判断传过去的验证码和cookie里的验证码让否一致