[eluser]doubleplusgood[/eluser]
Hi there,
I have built and admin controller and would like the is_valid_user function to check the email address and also check that that user has a particular group/access level.
My login and is_valid_user functions are as follows;
Code:
function login()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
if ( empty($email) || empty($password) )
{
die('fill it in!');
}
$logged_in = $this->auth->login($email, $password);
redirect('admin');
}
function is_valid_user($email)
{
$this->db->where('email', $email);
$query = $this->db->get('users', 1);
if ( $query->num_rows() == 1 )
{
return TRUE;
}
else
{
$this->form_validation->set_message('is_valid_user', 'This user is not registered!');
return FALSE;
}
}
I attempted the following query to check the email and groupid (access level);
Code:
$sql = "SELECT * FROM users WHERE email = ? AND groupid = ?";
$this->db->query($sql, array($email,5));
$query = $this->db->get('users', 1);
I wondered if anyone had any ideas on how to get this working? Thank you.