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