[eluser]Mainboard[/eluser]
hey everyone, really i need a little help xD, how i can to pass the $id in my foreach model to the array in my controll, this is my code
my model
Code:
function validate()
{
$this->default_db = $this->load->database('default', true);
$query = $this->default_db->select('*')->from('tb_membership')
->where('username', $this->input->post('username'))
->where('password', sha1($this->input->post('password')));
$query = $this->default_db->get();
//return $query;
if($query->num_rows() == 1)
{
foreach ($query->result() as $row)
{
$id = $row->id;
}
return true;
}
}
my controll
Code:
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // si las credenciales del usuario son validas...
{
$data = array(
'username' => $this->input->post('username'),
//----> $id
'is_logged_in' => true
);
//return $query->row('id');
$this->session->set_userdata($data);
redirect('site/members_area');
}
else // incorrect username or password
{
$this->index();
}
}
i just only need to catch the $id in the session but first i need to put the id in the array, im new in CI, so y need a little help with this xD