Welcome Guest, Not a member yet? Register   Sign In
Using Validation LIbrary to Check Database for Username AND password
#1

[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.
#2

[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/erka...n-library/

PS - what's the deal with all the 'this is me and my chick' avatars around here?
#3

[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...
#4

[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";
$rules['username'] = "trim|required|min_length[1]|max_length[50]|alpha_dash|xss_clean|callback_checkUsernamePassword";

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.




Theme © iAndrew 2016 - Forum software by © MyBB