ThinkPHP verification code use a concise tutorial. 1. First, add the verification code method adminLibActionLoginAction. class. php to the controller. knowledge points: 1. use of the ob_clean function. 2. call the think default class library by using the import method. 3. Image class.
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: