Welcome Guest, Not a member yet? Register   Sign In
Form Validation Callback for Matching Password
#2

[eluser]CroNiX[/eluser]
Code:
$this->form_validation->set_rules('old_password', 'Old Password', "trim|required|callback_password_matches[$admin_id]");

The first value passed to your callback will always be the form field value, any additional values can be passed within brackets (see above) and will be received as the 2nd parameter of the callback.

Code:
public function password_matches($submitted_value, $admin_id)
{
  //load your admin by id, validate current password.
  if (password_wrong)
  {
    $this->form_validation->set_message('password_matches', 'The password you supplied does not match your existing password.');
    return FALSE;
  }

  //check to see if the new password matches the reentered new password...
  if ($submitted_value !== $this->input->post('confirmation_password'))
  {
    $this->form_validation->set_message('password_matches', 'The confirmation password does not match.');
    return FALSE;
  }

  //passed...
  return TRUE;
}


Messages In This Thread
Form Validation Callback for Matching Password - by El Forum - 09-06-2012, 11:37 AM
Form Validation Callback for Matching Password - by El Forum - 09-06-2012, 12:18 PM
Form Validation Callback for Matching Password - by El Forum - 09-06-2012, 12:52 PM
Form Validation Callback for Matching Password - by El Forum - 09-06-2012, 12:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB