[eluser]Unknown[/eluser]
I am trying to pass over the ID field of a query to pass into session data in my Controller.
I can echo the ID out successfully, but I have no idea how to move that data into my controller.
Code:
function validate(){
$this->db->where('username', $this->input->post('user'));
$this->db->where('password', sha1($this->input->post('pass')));
$query = $this->db->get('users');
if($query->num_rows == 1){
foreach($query->result() as $row):
$userID = $row->id;//echoing this works
endforeach;
return $userID;
}
}
When I try to use $userID in my controller, it throws an error of undefined variable. How do I get this variable into my controller?
Sorry if this is a nooby question, I just started learning codeigniter and I am porting one of my current websites from regular php to codeingiter.