Home  >  Article  >  php教程  >  thinkphp3.2.1坑爹的一次性验证码,ajax要2次验证啊!

thinkphp3.2.1坑爹的一次性验证码,ajax要2次验证啊!

WBOY
WBOYOriginal
2016-06-07 11:34:37932browse

验证码为什么要加密?加密也就算了,为什么还在一次性失效的前题下加密?
找了半天也没找到解决好的解决方案。最后决定把自带的验证码验证拿出来用于ajax,二次验证照样过。$verify = new \Think\Verify();<br>             global $seKey;<br>                $seKey = $verify->seKey;<br>             function authcode($str){<br>                 $key = substr(md5($GLOBALS['seKey']), 5, 8);<br>                 $str = substr(md5($str), 8, 10);<br>                 return md5($key . $str);<br>             }<br>             function check($code, $id = '') {<br>                 $key = authcode($GLOBALS['seKey']).$id;<br>                 // 验证码不能为空<br>                 $secode = session($key);<br>                 if(empty($code) || empty($secode)) {<br>                     return false;<br>                 }<br>                 if(authcode(strtoupper($code)) == $secode['verify_code']) {<br>                     return true;<br>                 }<br>                 return false;<br>             }<br>             if (check(I('verify'))) {<br>                 $this->success('验证码正确', $_SERVER['HTTP_REFERER']);<br>             } else {<br>                 $this->error('验证码错误', $_SERVER['HTTP_REFERER']);<br>             }Q907999456
http://blog.xuanzeta.com

AD:真正免费,域名+虚机+企业邮箱=0元

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