Home > Backend Development > PHP Problem > php different users jump to different pages

php different users jump to different pages

Release: 2023-02-28 07:10:01
Original
5060 people have browsed it

php different users jump to different pages

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;
    }
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template