phpDifferent users jump to different pages:
1. Password verification
The username and password submitted by the view layer here are not encrypted , the password in the data is encrypted by md5, so the password is encrypted first, and then compared with the records in the database. If they are consistent, it is considered successful.
2. Session saving
If the verification is successful, the user information will be saved in the session.
3. Jump according to different permissions
Sometimes we display different pages for different users. In this case, we need to jump to the corresponding page according to the user's permissions.
4. Implementation code
// 登录 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; } }
Recommended: php server
The above is the detailed content of php different users jump to different pages. For more information, please follow other related articles on the PHP Chinese website!