thinkphp Framework Extension Package Usage details--Verification code example (11)

Source: Internet
Author: User

How to expand the use of compressed package details


1: Unzip the expansion pack: Thinkphp3.1.2_extend.zip and copy all the \extend files under it

2: Put the copied files into the project E:\wamp\www\thinkphp\ThinkPHP\Extend (this is empty file when installed), your own project directory

Can


============================= below is the use of the verification code in the expansion package ========================================

For example, use the verification code of the extension package: (see Manual--miscellaneous)

In: E:\wamp\www\thinkphp\Home\Lib\Action\ NEW: PublicAction.class.php code is as follows--must be added

Generate verification code directly using code

Class Publicaction extends action{//follow the manual instructions.

Function Code() {
Import (' ORG. Util.image ');
Image::buildimageverify ();
}

}


//Directory/thinkphp/index.php/public/code Click the Transform Verification code onclick

Foreground template page Call verification code:

to generate verification code


All HTML login pages

<form action= ' __url__/do_login ' method= ' post ' name= ' MyForm ' >

User name: <input type= ' text ' name= ' username '/><br/>
Password: <input type= ' password ' name= ' password '/><br/>
CAPTCHA: <input type= ' text ' name= ' code '/>

</br/>

</form>


Login Verification Code Plus: LoginAction.class.php (module)


ClassloginactionExtends Action {
function Do_login () {
Get the user name and password, and so on. And in the database, there is a user allowed to log on otherwise output error page
$username =$_post[' username '];
$password =$_post[' password '];
$code =$_post[' code '; input box; <input type= ' text ' name= ' code '/>

if ($_session[' verify ']!==md5 ($code)) {
$this->error (' Authenticode Error! ‘);
}


$m =m (' User ');
$where [' username ']= $username;
$where [' Password ']= $password;
$i = $m->where ($where)->count ();
if ($i >0) {
$this->redirect (' User/index ');
}else{
$this->error (' The user does not exist ');
}
}
}

thinkphp Framework Extension Package Usage details--Verification code example (11)

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.