![]() |
Using Validation LIbrary to Check Database for Username AND password - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Using Validation LIbrary to Check Database for Username AND password (/showthread.php?tid=8201) |
Using Validation LIbrary to Check Database for Username AND password - El Forum - 05-09-2008 [eluser]Eric Cope[/eluser] Hello all, I am validating some user input against a database. If I can't find the username/password pair in the database, I want to fail validation. Is there a function I can call to fail validation to trigger an error message? Thanks. Using Validation LIbrary to Check Database for Username AND password - El Forum - 05-09-2008 [eluser]GSV Sleeper Service[/eluser] yep, the validation callback functions. see the validation docs for more details, or see here for a good example - http://www.michaelwales.com/2007/10/erkana-codeigniter-authorization-library/ PS - what's the deal with all the 'this is me and my chick' avatars around here? Using Validation LIbrary to Check Database for Username AND password - El Forum - 05-09-2008 [eluser]Eric Cope[/eluser] I am familiar with callback functions. I did not think they support multiple field inputs. Regarding the avatar, I just took it from my gmail account. So for me, its laziness... Using Validation LIbrary to Check Database for Username AND password - El Forum - 05-09-2008 [eluser]Eric Cope[/eluser] I forgot that $this->input-><fields> was available in the callback functions. Don't I feel like a horse's <>. Yet again Michael Wales saves the day! -Edit- What order are the input fields validated? If for example, I reference $this->input->password before it was validated, it may contain "dirty" data. I should wait for it to be validated first, right? -Edit- It looks like it validates in the order that you identify rules. Code: $rules['password'] = "trim|required|min_length[1]|max_length[50]|alpha_dash|xss_clean"; In this instance, the password is verified first, then the username. The rules are also processed in the order they are listed, so put rules that are more likely to fail first. |