Using Validation Class to validate Username and Password - 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: Using Validation Class to validate Username and Password (/showthread.php?tid=15911) |
Using Validation Class to validate Username and Password - El Forum - 02-18-2009 [eluser]chadsaun[/eluser] I'm new to Codeigniter and need some help to figure out the best way to validate the username and password. This is what I have so far, but I want to setup some validation rule for validating if the username and password were found in the DB so that if it wasn't they'll see an error message. Code: function authorize() { Using Validation Class to validate Username and Password - El Forum - 02-18-2009 [eluser]Mark Skilbeck[/eluser] You want to check out callbacks. Code: $this->form_validation->set_rules('username', 'Username', 'trim|required|max_length[50]|xss_clean|callback_username_exists'); Using Validation Class to validate Username and Password - El Forum - 02-18-2009 [eluser]chadsaun[/eluser] I looked at callbacks, but from what I understand the callback will only be passed the form field it was attached to. So you couldn't get both the username and password. How would I do this with a callback? Using Validation Class to validate Username and Password - El Forum - 02-19-2009 [eluser]TheFuzzy0ne[/eluser] I don't understand what you mean. Using Validation Class to validate Username and Password - El Forum - 02-19-2009 [eluser]Colin Williams[/eluser] You can get the other fields' value in the callback with $this->input->post('other_field') |