homepage not loading. after signing in it redirects to signin instead of homepage
the login function. id like to know where im going wrong in this
controller
public function login(){
$this->load->library('session');
$this->load->model('Model_students');
$email = $_POST['email'];
$password = $_POST['password'];
$data = $this->Model_students->login($email, $password);
if($data)
{
$id=$data[0]->id;
$first_name=$data[0]->firstname;
$last_name=$data[0]->lastname;
$this->session->set_userdata('user_id',$id);
$this->session->set_userdata('lname',$last_name);
$this->session->set_userdata('user', $email);
$this->session->set_userdata('fname',$first_name);
$this->getImg();
redirect('Students/homepage');
}
else{
$this->session->set_flashdata('error','Invalid login. User not found');
}
}
public function getImg()
{
$userid=$this->session->userdata('user_id');
$res=$this->Model_students->getimge($userid);
$img=$res[0]->userfile;
$img1=json_decode($img);
$this->session->set_userdata('img',$img1);
}
model
public function login($email,$password)
{
$query = $this->db->get_where('users', array('email'=>$email));
if($query->num_rows() == 1 )
{
return $query->result();
}
}
public function getimge($userid)
{
$query = $this->db->get_where('user_images', array('user'=>$userid));
if($query->num_rows() == 1 )
{
return $query->result();
}
}
after i sign in using credentials the page redirects to the signin instead of loading the view of the homepage.where could the problem be because it when i run this doesn't work as its supposed to