Welcome Guest, Not a member yet? Register   Sign In
Form Validation -> multiple fields as arguments
#3

[eluser]David Johansson[/eluser]
You are very close.
First, you have to decide which field to apply the rule on. Lets say you apply the rule on the email field, then you should write:
Code:
array(
      'field'    =>    'email',
      'label'    =>    'Email',
      'rules'    =>    'callback__in_db[password]'
      //does SELECT COUNT(*) FROM tbl WHERE email = 'field_email'
)

and your function _in_db could look something like:

Code:
function _in_db($email, $password_field)
{
    $password = $this->input->post($password_field);
    //Then you make your db query and return true if the result is one otherwise false
}

If you are using the build in error messages you should do something like:
Code:
$this->form_validation->set_message('_in_db', 'Wrong %s or %s.');
which would produce something like "Wrong Email or Password".


Messages In This Thread
Form Validation -> multiple fields as arguments - by El Forum - 07-21-2009, 02:50 PM
Form Validation -> multiple fields as arguments - by El Forum - 07-21-2009, 03:59 PM
Form Validation -> multiple fields as arguments - by El Forum - 07-21-2009, 11:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB