Thinkphp3.2 click to refresh to generate verification code _ PHP

Source: Internet
Author: User
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:

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.