
php差别用户跳转差别页面:
一、暗码校验
这里view层提交过来的用户名和暗码是不加密的,数据中的暗码是经由md5加密的,所以起首对暗码举行加密,然后跟数据库中的纪录比对,假如一致则以为胜利。
二、session保留
假如校验胜利则将用户信息保留在session中。
三、依据差别权限跳转
有时候我们关于差别的用户展现的页面也差别,这时候就需要我们依据用户的权限跳转到响应的页面。
四、完成代码
// 登录 public function login() { //暗码加密并从数据库查找纪录 $map['username'] = input('post.a'); $map['password'] = md5(input('post.b')); $user=db('user')->where($where)->find(); //考证胜利则保留session if ($user) { unset($user["psd"]); session("user", $user['id']); //依据差别权限跳转 if($user['quanxian'] == 0){ $this->redirect('Module1/index/index'); } elseif ($user['quanxian'] == 1) { $this->redirect('MOdule2/index/index'); } else{ $this->redirect('Module3/index/index'); } }else{ print_r ('error!'); return false; } }
引荐:php服务器
以上就是php差别用户跳转差别页面的细致内容,更多请关注ki4网别的相干文章!