Validation helper for login form? |
[eluser]inktri[/eluser]
So there are input fields: Username and Password I want to make a rule so that size of: Code: select id from users where username = 'username' and password = md5('password') limit 1; This rule needs data in both Username and Password fields. How would you go about creating a rule which requires data from multiple fields such as the case above Thanks for the help
[eluser]wiredesignz[/eluser]
Set rules for both fields `required` for a start, and then use a callback rule on the password field.
[eluser]TheFuzzy0ne[/eluser]
[quote author="inktri" date="1209186387"]So there are input fields: Username and Password I want to make a rule so that size of: Code: select id from users where username = 'username' and password = md5('password') limit 1; This rule needs data in both Username and Password fields. How would you go about creating a rule which requires data from multiple fields such as the case above Thanks for the help[/quote] I'm not entirely sure what you're asking, but I believe you should be able to find your answer here. If not, please could you be more specific with your question?
[eluser]inktri[/eluser]
within the username_check_login rule function, $str contains the username in the username input field. How can I access the password in the passsword input field from within the username_check_login function? Code: <?php
[eluser]wiredesignz[/eluser]
I actually said do the callback rule on the password field. You can pass the field contents from validation to the callback function. Read the User Guide.
[eluser]TheFuzzy0ne[/eluser]
[quote author="inktri" date="1209188073"]within the username_check_login rule function, $str contains the username in the username input field. How can I access the password in the passsword input field from within the username_check_login function? Code: <?php Perhaps a callback isn't what you need? I would instead recommend that you maybe create a helper file, and then call the function you need from inside the controller. Trying to do it the way you currently are is likely to cause problems. The callback is for 1 field only, so I don't think I'd try mixing the two together. Hope this helps.
[eluser]inktri[/eluser]
I managed to fix the problem using wiredesignz's solution. Create a password callback function and within it you can reference the username field with: $this->validation->username
[eluser]TheFuzzy0ne[/eluser]
[quote author="inktri" date="1209247934"]I managed to fix the problem using wiredesignz's solution. Create a password callback function and within it you can reference the username field with: $this->validation->username[/quote] Good thinking. I misread one of your posts and missed what you were getting at. I'm not sure if this is intentional, but I noticed that username_check_login only returns true or false, but can be called upon via the Router class, and thus the general public. |
Welcome Guest, Not a member yet? Register Sign In |