根据client_type登录后,我想在codeigniter中显示一个仪表板。请帮忙。
这是我的控制器登录:
public function login()
{
$data['error'] ="Invalid Login";
$this->load->view('auth/header');
if($this->input->post())
{
$user = $this->UserModel->login($this->input->post());
if(count($user)>0)
{
$array = array(
'client_id' => $user['client_id'],
'email' => $user['email'],
'password' => $user['password'],
);
$this->session->set_userdata($array);
}
else
{
$data["error_message"]="Invalid User Name and Password combination";
}
//$this->UserModel->login($this->input->post());
//redirect(base_url('../fms'));
}
$this->load->view('auth/signin',$data);
$this->load->view('auth/footer');
}
答案 0 :(得分:1)
试试这可能会对你有帮助,
public function login()
{
$data['error'] ="Invalid Login";
$this->load->view('auth/header');
if($this->input->post())
{
$user = $this->UserModel->login($this->input->post());
if(count($user)>0)
{
$array = array(
'client_id' => $user['client_id'],
'email' => $user['email'],
'password' => $user['password'],
'username' => $user['username']
);
$this->session->set_userdata($array);
if($user['client_type_id'] == '1'){
redirect(base_url('your_controller/admin_dashboard'));
} else {
redirect(base_url('your_controller/client_dashboard'));
}
}
else
{
$data["error_message"]="Invalid User Name and Password combination";
}
//$this->UserModel->login($this->input->post());
//redirect(base_url('../fms'));
}
$this->load->view('auth/signin',$data);
$this->load->view('auth/footer');
}
function admin_dashboard(){
$this->load->view('admin/header');
$this->load->view('admin/home',$data);
$this->load->view('admin/footer');
}
function client_dashboard(){
$this->load->view('client/header');
$this->load->view('client/home',$data);
$this->load->view('client/footer');
}