A simple way to use verification codes in thinkphp,
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, save the value of the generated verification code with the SESSION: Copy the 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:
The copy Code code is as follows: can realize the click Refresh function
The display results are 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.
Articles you may be interested in:
- Using the Ueditor Rich Text editor in thinkphp
- thinkphp integrated Baidu Ueditor Graphic tutorial
- thinkphp automatic Escape solution for reading errors caused by storing rich text editor content
- Example analysis of page usage in thinkphp
- How to use thinkphp under Ueditor
http://www.bkjia.com/PHPjc/1084519.html www.bkjia.com true http://www.bkjia.com/PHPjc/1084519.html techarticle The simple use method of verification code in thinkphp, this paper describes the simple use of verification code in thinkphp. Share to everyone for reference, as follows: first generate verification code, ...