Verification code
There is still one step left before the login is completed, the verification code. The verification code can effectively prevent malicious login.
Verification code
PHP中文网:交流群374224296
LoginController.class.php
create($_POST,4)){ if($admin->login()){ $this->success('登录成功,跳转中...',U('Index/index')); }else{ $this->error('用户名或者密码错误!'); } }else{ $this->error($admin->getError()); } return; } $this->display(); } public function verify(){ $Verify = new \Think\Verify(); $Verify->length=4; $Verify->entry(); } }
In the member’s model layer AdminModel.class.php
password; $info=$this->where("username='$this->username'")->find(); if ($info){ if($info['password']=md5($password)){ return true; }else{ return false; } }else{ return false; } } public function verify($code){ $verify =new \Think\Verify(); return $verify->check($code,''); } }