Welcome Guest, Not a member yet? Register   Sign In
Form Validation Matches Error
#1

[eluser]Unknown[/eluser]
I am trying to validate a form with two emails address on. The second email address must match the first for the validation to succeed.

Here is a snippet of validation code

Code:
$this->form_validation->set_rules('fm-email', 'Email', 'required|trim|valid_email|strtolower');
$this->form_validation->set_rules('fm-email2', 'Email Confirm', 'required|trim|valid_email|strtolower|matches[fm-email]');

As the rules cascade they are processed one by one and i assumed that if a user entered an email address in one field all uppercase and an email address all lowercase in the second field they would still match as both addresses would've been trimmed and lowercased before matching.

I've gone through the core code and it seems like they are indeed processed correctly except the codeigniter matches code uses the original post array and so the validation fails (the original array has upper and lower case and non trimmed characters)

Code:
//CodeIgniter core code
function matches($str, $field)
{
  if ( ! isset($_POST[$field]))
  {
   return FALSE;
  }

  $field = $_POST[$field]; //Global post array??
                
  return ($str !== $field) ? FALSE : TRUE;
}

Is this the correct behaviour or should the $_POST really refer to the internal post array codeigniter is using (hence a bug??)
#2

[eluser]Unknown[/eluser]
*** BUMP *** Anyone?? Bug or not ?!
#3

[eluser]prakash[/eluser]






Theme © iAndrew 2016 - Forum software by © MyBB