2016/05/11 thinkphp 3.2.2 Verification code use and verification

Source: Internet
Author: User

Create a new public controller to place the instantiation Code of the CAPTCHA (no new controller is OK, any public controller can).

Example: PublicController.class.php

142536475869710811912Ten13 One14 A15 -16 -17 the18 -<?PHP - namespace Home\controller; -      UseThink\controller; +     classPubliccontrollerextendscontroller{ -          Public functionindex () { +             $this-display (); A         } at          Public functioncode () { -             $config=Array(     -' FontSize ' = 30,//captcha Font Size -' Length ' = 3,//Verify number of code bits -' Usenoise ' =true,//turn off the captcha clutter. -             ); in             $verify=New\think\verify ($config); -             $verify-entry (); to         } +     } -?>

And then the page template inside the need to insert a verification code place to insert code (referring to the above instantiation of the model function, the onclick attribute is to click on the image to change a verification code):

Write the following code to test the verification code in the From form's Action submission location:

1  Public functionDo_login () {2 if(!Empty($_post)){3 $verify=New\think\verify ();4 if(!$verify->check ($_post[' Code '])){5 Echo"Captcha Error";6}Else{7 Echo"Verification code is correct";8 }9 }Ten}

Verify that the code entered is correct and the error is displayed incorrectly.

2016/05/11 thinkphp 3.2.2 Verification code use and verification

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.