Why is verification code always incorrect in yii Framework?

Source: Internet
Author: User
Why is the verification code always incorrect in the yii Framework my view page?
My controller
The formmodel page
I tried a lot of writing methods. do you want to verify it? if you're right, he just told me that the verification code is incorrect. I really don't know what to do. please help me ~~~


Reply to discussion (solution)

Haha, I solved it myself !! I added a line to the framework verification code class before the public function run () is incorrect ()
{
// $ This-> fixedVerifyCode = substr (mt_rand (),); // optimize the verification code
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 ();
}

After adding that line of optimization verification code, the comment is correct.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.