Re: Case sensitive password
| From: | R.C. | Date: | Thu, 19 Jun 2008 15:55:33 +0000 |
| Subject: | Re: Case sensitive password | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275613@lists.php.net to get a copy of this message | ||
Nathan,
Thank you ... very thorough.
Best
R.C.
""Nathan Nobbe"" <quickshiftin@gmail.com> wrote in message
news:7dd2dc0b0806182145l55f67b29l84218f0a7331ea0e@mail.gmail.com...
> i hate posting the same answer to a given question thats already been
> posted, but i had this all typed in when chris submitted his answer, so
here
> it is again..
>
> On Wed, Jun 18, 2008 at 10:36 PM, R.C. <rme@besttranslation.org> wrote:
>
> > I have coded a php page that accepts a password. What is the code to
make
> > sure the password entered is NOT case-sensitive?
>
>
> when you store the password, you can store it as all upper or all
lowercase,
> then when comparing against the stored value, do the same operation to the
> value supplied from the user, and compare those. and you dont have to
> modify the original value if you dont want to, when you store it. just
> remember to alter both the stored value and the user-supplied value when
> doing comparisons.
>
> /// here is an example comparison
> // get password value from db for user, put it in $storedPassword
> // suppose the value the user supplied in a form is in variable
> $userSuppliedPassword
> // now for the case insensitive comparison
> if(strtolower($storedPassword) == strtolower($userSuppliedPassword))
> // passwords are the same
> else
> // passwords are different
>
> also note in the above example, there is no encryption of the password,
> which you almost certainly want to have ;)
>
> -nathan
>