我想创建多个用户登录名,但每个用户级别都有不同的重定向页面,仅供参考,在我的代码中只能在 1 个页面上重定向,无论级别 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>";
}
}
}
登录时,根据级别条件在重定向 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'));
}
}
}