Using Form_validation to check if username exists AND if password matches - 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 Form_validation to check if username exists AND if password matches (/showthread.php?tid=32161) |
Using Form_validation to check if username exists AND if password matches - El Forum - 07-14-2010 [eluser]dallen33[/eluser] I can't seem to get this working. The username part works fine, but I can't figure out how to check if the password matches. I know why it doesn't work, because to check the password, I also need to know the username. But the way the form validation callback works, I can't really do that. Am I doing something wrong or should I go about this another way? I just want it so if someone logs in and their password doesn't match, an error is shown. Controller : admin.php Code: function login() Library - auth.php Code: function login($a) Model - auth_model.php Code: function login_check_password($a) Config - form_validation.php Code: 'login' => array( Using Form_validation to check if username exists AND if password matches - El Forum - 07-14-2010 [eluser]pickupman[/eluser] Form validation is too make sure form fields are to be filled in the way you want them to, and to assist in repopulating the fields. I agree callback could work a little better. The easier way to do this is to check if required fields are filled out. In form->validation->run() routine pass username and password to auth library like: Code: if($this->form_validation->run() && $this->auth->login($user, $pass)){ You could add set_flashdata(), and return a message to the user why login faild. |