Form Validation -> multiple fields as arguments - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Form Validation -> multiple fields as arguments (/showthread.php?tid=20787) |
Form Validation -> multiple fields as arguments - El Forum - 07-21-2009 [eluser]Ickes[/eluser] Hello. I want to validate a member exists based upon their submitted email and password. I would like to do this via one callback in the form validation. Can someone let me know how I could pass the 2nd field as an argument? I know I can do... Code: array( Essentially, how do I accomplish one callback that does the equivalent of SELECT COUNT(*) FROM tbl WHERE email = 'field_email' AND password = 'field_password'? Is it possible to do a 'rules' => 'callback__in_db[second_field_to_pass]? I've tried and can't figure out the reference for second_field_to_pass if that is possible. Thanks in advance. Form Validation -> multiple fields as arguments - El Forum - 07-21-2009 [eluser]coolgeek[/eluser] you can access the $_POST array directly Form Validation -> multiple fields as arguments - El Forum - 07-21-2009 [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( and your function _in_db could look something like: Code: function _in_db($email, $password_field) 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.'); |