This article mainly introduces the TP framework (thinkphp) to achieve three login password error after locking the account function, combined with an instance of the form of analysis based on thinkphp landing judgment, the operation of the flag bit operations to achieve the password account lockout function, the need for friends can refer to the next
The example of this article describes the TP framework (thinkphp) to achieve three login password error after the lock account function. Share to everyone for your reference, as follows:
Tables in the database require the number of bars with control data name,pwd,number
Every time you enter the wrong password, the number-1 in the database is equal to 0 o'clock lock
Public Function Login_do () { //account $username =$_post[' username '); Password $pwd =$_post[' pwd ']; $user =m (' table name '); $list = $user->where ("Username= ' $username '")->find (); $time =date ("Ymd", Time ()); if ($list [' num ']==0) { if ($list [' Time ']!= $time + 1) { $this->error ("Your account is locked");} } if ($list) { if ($list [' pwd ']== $pwd) { $data [' id ']= $list [' id ']; $data [' num ']=3; $user->save ($data); $this->success ("Landing Success"); } else{ $list [' num ']=--$list [' num ']; $data [' num ']= $list [' num ']; $data [' id ']= $list [' id ']; $data [' Time ']= $time; $user->save ($data); $this->error ("Password is wrong, you can also enter". $list [' num ']. " Times "); } } else{ $this->error ("account Error");} }
Articles you may be interested in:
PHP implementation Generate data Dictionary function example
CodeIgniter Framework Database Basic operation of the relevant explanation
PHP Get all dates for this week or the last seven days all dates method