好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php不同用户跳转不同页面

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不同用户跳转不同页面的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于php不同用户跳转不同页面的详细内容...

  阅读:47次