[eluser]pickupman[/eluser]
Form validation is too make sure form fields are to be filled in the way you want them to, and to assist in repopulating the fields. I agree callback could work a little better. The easier way to do this is to check if required fields are filled out. In form->validation->run() routine pass username and password to auth library like:
Code:
if($this->form_validation->run() && $this->auth->login($user, $pass)){
redirect('user'); //Login successful
}else{
$this->login(); //Load login page again
}
//IN auth->login
function login($user = FALSE, $pass = FALSE){
if($user == FALSE || $pass == FALSE) return FALSE; //We need both credentials
$query = $this->db_common->get_where('users', array('username' => $user, 'password' => md5($pass), 1 );
if($query->num_rows() > 0)
return $query->row(); //Return user credentials
return FALSE; //Sorry user wasn't found
}
You could add set_flashdata(), and return a message to the user why login faild.