[eluser]afro[/eluser]
the model class is has follows
Code:
function getusergroup()
{
$query = $this->db->select('usergroup');
$this->db->from('users');
$array = array('username' =>$this->input->post('username'), 'password' => md5($this->input->post('password')));
$this->db->like($array);
$ret['usergroup'] = $query->get()->result();
return $ret;
}
The controller class is has follows
Code:
function check()
{
$admin = $this->session->userdata('usergroup') == 'Systems Administrator';
$staff = $this->session->userdata('usergroup') == 'staff';
$client = $this->session->userdata('usergroup') == 'client';
if(isset($admin))
{
$this->load->view('admin/home');
return true;
}
else if(isset($staff))
{
$this->load->view('public/home');
return true;
}
else if(isset($client))
{
$this->load->view('public/home');
return true;
}
else if($this->session->userdata('usergroup') == '')
{
$this->load->view('public/home');
return true;
}
else
{
return false;
}
}
I call the check function after the users have logged in
Code:
if($query)
{
$usergroup = $this->Welcome_model->getusergroup();
$group = $usergroup['usergroup'];
//load userdata to database//
$data = array(
'username' => $this->input->post('username'),
'usergroup'=>$group,
'is_logged_in' => true
);
$this->session->set_userdata($data);
$this->check();
}