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: