[eluser]Michael Wales[/eluser]
Code:
function index() {
$this->load->library('validation');
$rules['username'] = 'callback__check_login';
$rules['password'] = '';
$this->validation->set_rules($rules);
// ... more code here ... //
if ($this->validation->run()) {
// Login was valid
} else {
// Login invalid or the form was not submitted
}
}
function _check_login($username) {
// Get our password, you can use any of the following - they are all the same at this point:
// - $this->validation->password;
// - $this->input->post('password');
// - $_POST['password'];
$password = md5($_POST['password']);
// ... SQL to determine if it's a good login or not ..
if ($login === TRUE) {
return TRUE;
} else {
$this->validation->set_message('_check_login', 'Bad username/password');
return FALSE;
}
}