Re: Case sensitive password
| From: | Daniel Brown | Date: | Thu, 19 Jun 2008 20:32:47 +0000 |
| Subject: | Re: Case sensitive password | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275653@lists.php.net to get a copy of this message | ||
On Thu, Jun 19, 2008 at 4:18 PM, R.C. <rme@besttranslation.org> wrote:
> Andrew,
>
> That is correct. Only ONE password to access a restricted page for selected
> people. But... they want to make that ONE password case-insensitive. I
> added the following code with 2 variables now, one being upper case, one
> being lower case but that, of course, doesn't cover all the variatons on the
> "video" word. I'm looking for the code to make this whole word
> case-insensitive, no matter which letter is cap or not.... can you add to
> this code below please?
>
> session_start();
>
> $_SESSION ['userpass'] = $_POST ['pass'];
> $_SESSION ['authuser'] = 0;
>
> $login = "VIDEO";
> $login2 = "video";
>
> if (($_SESSION['userpass'] == $login) or ($_SESSION['userpass'] ==
> $login2))
> {
> $_SESSION['authuser'] = 1;
> ?>
Try this:
<?php
if(preg_match('/^'.$_SESSION['userpass'].'$/i',$login)) {
echo "Good.\n";
} else {
echo "Bad.\n";
}
?>
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.