This paper describes the simple use of verification code in thinkphp. Share to everyone for your reference, as follows:
First generate the verification code, in the action file, directly call the thinkphp provided in the method can be generated, to ensure that the extension of PHP GD2
As follows:
Class Useraction Model extends model{/** * Display Verification Code information */Public Function verify () { ob_clean ();///Erase (Erase) output buffer, i.e. empty the front Out, usually the verification code does not display, you can consider the issue of import (' ORG. Util.image '); Image::buildimageverify (); }}
At the same time, the value of the generated verification code is saved with the session:
Copy the Code code as follows:
$_session[' Verify ']
Note: The value that was saved after MD5 is encrypted .
In the corresponding TPL file, the verification code is called, using the following method:
Copy the Code code as follows:
The user submits the past verification code, which needs to be MD5 encrypted, compared with the saved session value , namely:
Determine if MD5 ($_post[' verify ') is equal to $_session[' verify '].
To complete the basic use of verification code
It is hoped that this article is helpful to the PHP program design based on thinkphp framework.
The above introduces the simple use of verification code in thinkphp, including the content of the contents, I hope that the PHP tutorial interested in a friend helpful.