登录判断是否成功?
- 内容介绍
- 文章标签
- 相关推荐
本文共计234个文字,预计阅读时间需要1分钟。
如果支付成功,会跳转到个人中心,否则跳转到其他页面。// 后台控制器方法public function h_login() { // 登录页面 if (IS_POST) { $data=I('post.'); $verify=new \Think\Verify(); // 验证码错误 $check=$verify->check($data['che']); }}
//后台控制器方法 public function h_login() { //登陆页面 if (IS_POST) { $data = I('post.'); $verify =new \Think\Verify();//验证码错误 $check = $verify->check($data['verify']); if (empty($data['username']) || empty($data['password'])) { $this->error('用户名或密码不能为空'); } if (!$check) { $this->error('验证码错误'); } $model = D('User'); $res =$model->where(array("username" => $data['username']))->find(); if ($res && $res['password'] == encrypt_password($data['password'])) { //encrypt_password 加密函数 session('user_info',$res); //设置登录标识 $this->success('登陆成功',U('Home/Center/center')); }else{ $this->error('用户名或密码不正确'); } }else{ $this->display(); } } //加密函数放到Common/function function encrypt_password($password) { $salt = 'dfskngflmgkosmfdofdlgf';//盐 加盐 $key = substr($salt, 3, 8); return md5(md5($password) . $key); }
本文共计234个文字,预计阅读时间需要1分钟。
如果支付成功,会跳转到个人中心,否则跳转到其他页面。// 后台控制器方法public function h_login() { // 登录页面 if (IS_POST) { $data=I('post.'); $verify=new \Think\Verify(); // 验证码错误 $check=$verify->check($data['che']); }}
//后台控制器方法 public function h_login() { //登陆页面 if (IS_POST) { $data = I('post.'); $verify =new \Think\Verify();//验证码错误 $check = $verify->check($data['verify']); if (empty($data['username']) || empty($data['password'])) { $this->error('用户名或密码不能为空'); } if (!$check) { $this->error('验证码错误'); } $model = D('User'); $res =$model->where(array("username" => $data['username']))->find(); if ($res && $res['password'] == encrypt_password($data['password'])) { //encrypt_password 加密函数 session('user_info',$res); //设置登录标识 $this->success('登陆成功',U('Home/Center/center')); }else{ $this->error('用户名或密码不正确'); } }else{ $this->display(); } } //加密函数放到Common/function function encrypt_password($password) { $salt = 'dfskngflmgkosmfdofdlgf';//盐 加盐 $key = substr($salt, 3, 8); return md5(md5($password) . $key); }

