Simple Login Verification
Creating the Login Class
1<?PHP2 classLoginactionextendsAction {3 functionindex () {4 $this-display ();5 }6 functionDo_login () {7 //get the user name and password, and so on. And in the database, there is a user allowed to log on otherwise output error page8 $username=$_post[' username '];9 $password=$_post[' Password '];Ten $code=$_post[' Code ']; One A if($_session[' Verify ']!==MD5($code) {//$_session[' verify ']tp the SESSION created by default does not need to be modified to code - $this->error (' Verification code Error! ‘); - } the - $m=m (' User '); - $where[' username ']=$username; - $where[' Password ']=$password; + $i=$m->where ($where),Count(); - if($i>0){ + $this->redirect (' User/index '); A}Else{ at $this->error (' The user does not exist '); - } - } - } -?>
Template for Login class
1 <div style= "width:400px;margin:0 Auto" >2 <form action= "__url__/do_login" method= " Post ">3 user name: <input type=" text "name=" username "/><br/>4 secret code:< Input type= "password" name= "pwd"/><br/>5 Verification Code: <input type= ' text ' name= ' code '/><br/> //src=code Class code method, Math.random () Avoid cache cannot refresh 6 <input type= "Submit" value= "Login"/>7 </form>8 </div>
To create a verification code class
1 <? PHP 2 class extends action{3 function code () {4 import (' ORG. Util.image '); 5 Image::buildimageverify (); 6 }7 }89 ?>
thinkphp Study 13