[eluser]Wogan[/eluser]
I'm getting a bizarre error with Form Validation. Maybe someone can point out what must be the obvious, lol.
This is the controller:
Code:
function index()
{
$config = array(
array('field' => 'username','label' => 'Username','rules' => 'required'),
array('field' => 'password','label' => 'Password','rules' => 'required')
);
$this->form_validation->set_rules($config);
if ($this->form_validation->run() == FALSE)
{
$this->load->view('user/login', $data);
}
else
{
/* Checks if username matches password, redirects as needed */
}
}
Ok. So I enter a valid username and password into the fields, it logs me in. I log out, clear all cookies, and I enter another set of credentials. This new set
should work - the necessary db records exist, they're following all the validation rules, everything.
Except that they don't work. Instead of passing to the else{}, the validator fails and loads the login view all over again. So I try printing $this->form_validation in event of failure, to see what the errors are.
Surprise! There aren't any - as far as the object itself seems to be concerned, everything passes muster.
So then I go and enter random jibberish into the username/password fields. The validator succeeds, and I get my "username/password invalid" error - the one that's checked for in the else{} block, after form validation.
It's not cookies/sessions in my browser - I've been clearing them on every attempt. It's also not some weird external library - all the controller loads is 'form_validation' in the __construct() bit, and makes use of helper functions like set_cookie() and redirect();
I'll be revisiting this rather fascinating problem in the morning, but I was wondering if anyone might have an idea or two to steer me in the right direction. I mean, how would I go about debugging this if, as far as CI is concerned, there
are no bugs?