ThinkPHP3.2 use verification code

Source: Internet
Author: User
Create a function. php In the Home-Common folder to save the public function? Phpfunctioncheck_verify ($ code, $ id1) {$ verifynewThinkVerify (); return $ verify-check ($ code, $ id );} this function is used to test the verification code and create a PublicContrroler in the Home-Contrroler folder.

Create a function. php In the Home-Common folder to save the public function? Php function check_verify ($ code, $ id = 1) {$ verify = new \ Think \ Verify (); return $ verify-check ($ code, $ id );} this function is used to test the verification code and create a PublicContrroler in the Home-Contrroler folder.

Create a function. php file in the Home-> Common folder to save the public functions.

Function check_verify ($ code, $ id = 1 ){
$ Verify = new \ Think \ Verify ();
Return $ verify-> check ($ code, $ id );
}

This function is used to verify the verification code.

In the Home-> Contrroler folder, create a PublicContrroler. class. php for public controllers. All other controllers are integrated with the following code to generate verification codes.

Public function verify ($ id = 1 ){
$ Config = ??? Array (
'Fontsize '??? ==> ??? 18 ,??? // Font size of the Verification Code
'Length '????? ==> ??? 4 ,???? // Number of digits of the Verification Code
'Imageh '????? ==> ??? 34, // disable the verification code Miscellaneous
'Usenoise '??? ==> ??? False, // disable the verification code Miscellaneous
'Usecurve '??? ==> ??? False,
);
$ Verify = new \ Think \ Verify ($ config );
$ Verify-> entry ($ id );
}

Call Verification Code

If a page contains multiple verification codes, you can add an ID parameter.

Verification Code

If (! Check_verify ($ verify1, 1 )){
$ This-> error ('verification code entered incorrectly! ');
}

The second parameter is id.

Click to reload the verification code based on jquery

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.