[eluser]rohanprabhu[/eluser]
When we use the form validator to set rules, we set those rules for a certain 'field'. For ex:
Code:
$this->form_validation->set_rules('username', 'Username', 'required');
asserts that the 'username' field must not be empty. However, i need to have a validation rule which performs authentication. Let's say this function is called 'perform_auth'. However, if i use it as a callback function:
Code:
$this->form_validation->set_rules('username', 'Username', 'callback_perform_auth');
this results in function call of the format:
Code:
Object::perform_auth($username)
i.e. i'm able to pass only one parameter to the function.. not both the username and password. My only need is to be able to set an error message if the username/password don't match:
Code:
$username = $this->input->post('username');
$password = $this->input->post('password');
if($this->auth->perform_auth($username, $password) == false) {
$this->form_validation->set_message('upass_fail', "Username/Password don't match");
}
The above mentioned code doesn't work.. If i do <?php echo(validation_errors()); ?>, nothing is shown at all.. how do I go around this?
thanks,
rohan