This article mainly introduces the tp framework (thinkPHP) to implement the account locking function after three incorrect login passwords. It analyzes the password account locking function based on thinkPHP login judgment, flag operation and other operations based on examples. Friends in need can refer to it. Next
The example in this article describes how the tp framework (thinkPHP) implements the function of locking the account after three incorrect login passwords. Share it with everyone for your reference, the details are as follows:
The table in the database needs to have the number of control data name, pwd, number
Whenever you enter an incorrect password, the number-1, if it is equal to 0, it will be locked
public function login_do(){ //账号 $username=$_POST['username']; //密码 $pwd=$_POST['pwd']; $user=M('表名'); $list=$user->where("username='$username'")->find(); $time=date("Ymd",time()); if($list['num']==0){ if($list['time']!=$time+1){ $this->error("您的账号已被锁定"); } } if($list){ if($list['pwd']==$pwd){ $data['id']=$list['id']; $data['num']=3; $user->save($data); $this->success("登陆成功"); }else{ $list['num']=--$list['num']; $data['num']=$list['num']; $data['id']=$list['id']; $data['time']=$time; $user->save($data); $this->error("密码错误,还可以输入".$list['num']."次"); } }else{ $this->error("账号错误"); } }
The above is the entire content of this article, thank you for reading. Please pay attention to the PHP Chinese website for more information!
Related recommendations:
ThinkPHP5 framework cache query operation
The specific use of ThinkPHP5 validator
The above is the detailed content of The tp framework (thinkPHP) implements the function of locking the account after three incorrect login passwords. For more information, please follow other related articles on the PHP Chinese website!