CodeIgniter Forums
form validation and md5/sha1 - 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: form validation and md5/sha1 (/showthread.php?tid=20548)



form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]timaksu[/eluser]
hey guys..for the password field i have this:

Code:
$rules['password']    = "trim|required|min_length[6]|matches[passconf]|sha1";

it technically does what its supposed to until i try to repopulate the form(say, when the passwords don't match). instead of repopulating it with the previously entered password, it uses the sha1'ed version of the password string instead.


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]TheFuzzy0ne[/eluser]
If you don't want it to display that way in the form, then it would probably be wise not to call sha1 as a validation rule. Instead, call it as before you pass the data to your model.


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]Evil Wizard[/eluser]
And I assume your using password fields as input boxes? if so, why repopulate?


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]timaksu[/eluser]
[quote author="Evil Wizard" date="1247585992"]And I assume your using password fields as input boxes? if so, why repopulate?[/quote]

why not? its more convenient. i hate making a mistake on a forum (say, captcha). it reloads the page and asks you to do it again. you do, and submit once more. turns out it did not repopulate the form with your password, and you have to do that again..along with the captcha. happened more than once to me before, and if i can avoid it then why not.

(isnt that really the point of repopulating a form in the first place?
Quote:If you don’t want it to display that way in the form, then it would probably be wise not to call sha1 as a validation rule. Instead, call it as before you pass the data to your model.

what are possible uses for this then? the manual says this is simply another way to prep my data (in other words, "get it ready", yea?). Smile


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]TheFuzzy0ne[/eluser]
Yes, it is another way to prep data. An example of this type of usage might be trim(). That will trim any spaces, and display it in the form without the spaces.


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]timaksu[/eluser]
what about md5/sha1 though? they're effectively useless here?


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]TheFuzzy0ne[/eluser]
Yes, I would say so. Any prepping functions you use in your callbacks, should prep the output in a way you want it to be displayed in your form. Hopefully that make sense?


form validation and md5/sha1 - El Forum - 07-14-2009

[eluser]timaksu[/eluser]
yes it does. thanks Smile