Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 多用户登录重定向页面Codeigniter_Php_Codeigniter_Authentication_Session - Fatal编程技术网

Php 多用户登录重定向页面Codeigniter

Php 多用户登录重定向页面Codeigniter,php,codeigniter,authentication,session,Php,Codeigniter,Authentication,Session,我想创建多个用户登录,但是每个用户级别有不同的重定向页面,有两个级别供参考,在我的代码中只能重定向一个页面,无论级别1或2登录仍然指向一个页面,我想要的是每个级别都有自己的页面。。这是我的密码,请帮我谢谢 public function process() { $post = $this->input->post(null, TRUE); if(isset($post['login'])) { $this->load->model('m_u

我想创建多个用户登录,但是每个用户级别有不同的重定向页面,有两个级别供参考,在我的代码中只能重定向一个页面,无论级别1或2登录仍然指向一个页面,我想要的是每个级别都有自己的页面。。这是我的密码,请帮我谢谢

public function process()
  {
    $post = $this->input->post(null, TRUE);
    if(isset($post['login'])) {
      $this->load->model('m_user');
      $query = $this->m_user->login($post);
      if($query->num_rows() > 0){
        $row = $query->row();
        $params = array(
          'userid' => $row->id_user,
          'level' => $row->level
        );
        $this->session->set_userdata($params);
        echo "<script>
          alert('Login success');
          window.location='".site_url('klien')."';
        </script>";

      } else {
        echo "<script>
          alert('Login failed, wrong username/password');
          window.location='".site_url('auth/login')."';
        </script>";
      }
    }
  }
公共职能流程()
{
$post=$this->input->post(null,TRUE);
如果(isset($post['login'])){
$this->load->model('m_user');
$query=$this->m_user->login($post);
如果($query->num\u rows()>0){
$row=$query->row();
$params=数组(
'userid'=>$row->id\u user,
“级别”=>$row->level
);
$this->session->set_userdata($params);
回声“
警报(“登录成功”);
window.location='”.site_url('klien')。”;
";
}否则{
回声“
警报(“登录失败,用户名/密码错误”);
window.location=“.site_url('auth/login')”;
";
}
}
}

登录时,根据级别条件,在重定向URL中指定要转到的页面:

public function process() {
    $post = $this->input->post(null, TRUE);
    if (isset($post['login'])) {
        $this->load->model('m_user');
        $query = $this->m_user->login($post);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $params = array(
                'userid' => $row->id_user,
                'level' => $row->level
            );
            $this->session->set_userdata($params);
            echo "<script>alert('Login success');</script>";

            if($row->level == 1) // Level condition to redirect specific page with example level 1
                redirect('/pageX');
            else if($row->level == 2) // Level condition to redirect specific page with example level 2
                redirect('/pageY');
            //... more levels = more conditions
        } else {
            echo "<script>alert('Login failed, wrong username/password');</script>";
            redirect(site_url('auth/login'));
        }
    }
}
公共职能流程(){
$post=$this->input->post(null,TRUE);
如果(isset($post['login'])){
$this->load->model('m_user');
$query=$this->m_user->login($post);
如果($query->num\u rows()>0){
$row=$query->row();
$params=数组(
'userid'=>$row->id\u user,
“级别”=>$row->level
);
$this->session->set_userdata($params);
回显“警报(‘登录成功’);”;
if($row->level==1)//使用示例level 1重定向特定页面的level条件
重定向('/pageX');
else if($row->level==2)//使用示例level 2重定向特定页面的level条件
重定向('/pageY');
//…更多级别=更多条件
}否则{
echo“警报('登录失败,用户名/密码错误');”;
重定向(站点url(“身份验证/登录”);
}
}
}

请您描述一下,您的代码遇到的问题到底是什么?在我的代码中,只能在1页上重定向,无论级别1或2登录仍然指向一页,我希望每个级别都有自己的页面