ThinkPHP Verification Code use concise tutorial _ php instance

Source: Internet
Author: User
The verification code function is mainly used to prevent website login from being flushed. However, according to the common verification code function on the market, it is easy to bypass it. If you want to make the website safe enough, you 'd better study it further. 1. Add the verification code admin/Lib/Action/LoginAction. class. php to the Controller.
Knowledge point:
1. usage of the ob_clean Function
2. The import method calls the think default class library.
3. Use the Image buildImageVerify Method

The Code is as follows:

The Code is as follows:


Public function verify (){
Ob_clean ();
// The ob_clean function clears the previous output.
Import ('org. Util. image ');
// Import calls the Image. class. php class file in the Extend/Library/ORG/Util/extension package under the message/ThinkPHP framework directory.
Image: buildImageVerify ();
// Call the buildImageVerify method to generate the verification code. The default parameter is ($ length = 4, $ mode = 1, $ type = 'png ', $ width = 48, $ height = 22, $ verifyName = 'verify '). If you are interested, you can study the Image class.
}

2. Add the verification code module admin/Tpl/Login/index.html to the template file.
Knowledge point:
1. Verification Code image call
2. About js-related Running Processes
3./Public constant

Add the following code to the password input box:

The Code is 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.