//这是登录页面
public function login(){
// $this->display();
if(IS_POST){
$obj = new \Think\Verify();
if($obj->check(I('post.checkcode','','trim'))){
$admin_name = $_POST['username'];
$admin_pass = $_POST['password'];
$row = M('admin')->where("admin_name='$admin_name'")->find();
if($row){
//登录信息持久化$_SESSION
session('mg_username',$rst['mg_name']);
session('mg_id',$rst['mg_id']);
//跳转后台主页
$this->redirect("Manager/index");
}else{
$this->error("<script>alert('用户名或密码不正确')</script>",U('login'),0);
}
}else{
$this->error("<script>alert('验证码不正确')</script>",U('login'),0);
}
}
$this->display();
}
//生成验证码
public function verifyImg(){
$config = array(
'length' =>3 //验证码位数
);
$vimg = new \Think\Verify($config);
$vimg->entry();
}
转载于:https://www.cnblogs.com/sword082419/p/9268844.html