Home > Backend Development > PHP Tutorial > yii框架中验证码为什么总是验证错误

yii框架中验证码为什么总是验证错误

WBOY
Release: 2016-06-23 13:45:07
Original
827 people have browsed it

我的view页面
我的controller
那个formmodel页面
试了很多种写法 反正验证吗写对的 他就是给我说验证码错误 实在不知道怎么办了 求帮忙啊啊~~~


回复讨论(解决方案)

哈哈 我自己解决了 原是这样啊!!我在框架验证码那个类里加了一行后才不对的public function run()
{
//$this->fixedVerifyCode=substr(mt_rand(1,10000),0,4);//优化验证码
if(isset($_GET[self::REFRESH_GET_VAR]))  // AJAX request for regenerating code
{
$code=$this->getVerifyCode(true);
echo CJSON::encode(array(
'hash1'=>$this->generateValidationHash($code),
'hash2'=>$this->generateValidationHash(strtolower($code)),
// we add a random 'v' parameter so that FireFox can refresh the image
// when src attribute of image tag is changed
'url'=>$this->getController()->createUrl($this->getId(),array('v' => uniqid())),
));
}
else
$this->renderImage($this->getVerifyCode());
Yii::app()->end();
}

就加了那一行优化验证码后就不对了 注释掉后 就对了

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template