[eluser]condoace[/eluser]
I am trying to return the data selected (from model) to the controller. I am trying to store the row id in the $my_id variable that is located in the controller, but it doesnt seem to work (always empty).. any ideas what I am doing wrong..?
CONTROLLER
Code:
function validate_e_credentials()
{
$this->load->model('Model_employees');
$query = $this->Model_employees->validate_user();
$my_id = $query->id;
if($query == true) // if the user's credentials validated...
{
$data = array(
'user_id' => $my_id,
'login_email' => $this->input->post('login_email'),
'logged_in' => true
);
$this->session->set_userdata($data);
redirect('employees/index');
}
else // incorrect username or password
{
echo 'not working';
}
}
MODEL
Code:
function validate_user(){
$this->db->where('email', $this->input->post('login_email'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('employees');
if($query->num_rows == 1)
{
return $query->result();
}
}