This article mainly introduces thinkphp3.2 click to refresh the information to generate the verification code. if you need it, you can refer to the thinkphp3.2 verification code to introduce ThinkPHP verification code in detail. The details are as follows:
ThinkPHP has built-in support for verification codes and can be used directly. To use the verification code, you must import the ORG. Util. Image class library and ORG. Util. String class library in the extended class library.
Verification code method
We add a verify method to the module class to display the verification code. The simplest example is as follows:
Public function verify () {// import the Image class library import ("ORG. Util. Image"); Image: buildImageVerify ();}
The import method is the built-in class library and file import method of ThinkPHP. the file imported in the above example is the Lib/ORG/Util/Image. class. php file in the ThinkPHP system directory. If you have copied the Image class library to the current project, such as Lib/ORG, you can run the following command:
import("@.Util.Image");
The import method is the built-in class library and file import method of ThinkPHP. the file imported in the above example is the Lib/ORG/Util/Image. class. php file in the ThinkPHP system directory.
Access verification code
You can directly access the verification code method in the browser to determine whether the verification code can be properly displayed:
Http: // 127.0.0.1/index. php/Public/verify
If everything is normal, the verification code is displayed as follows:
Use verification code in the form
Use the verification code on the form page, which is called using the html img tag:
The src attribute value is the access address of the verification code method, which varies depending on the actual situation.
Refresh verification code
When you click the verification code image, the JavaScript changeVerify () function is triggered to re-read the verification code to refresh the verification code. The function is described as follows: