热搜:NVER node 开发 php

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

2024-08-17 16:55:02
yii框架中验证码为什么总是验证错误

我的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();
}

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