Re: problem using &&

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 26 Jul 2006 17:01:51 +0200, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
>> I sure wont.
>> On the topic of my array, what would be an efficient way of checking my
> username/passwordd pairs match the user input form my login form.
>> The text file contains username and passwords in the following format:
>> username1,password1
>> username2,password2
> 
> I dunno, something like this maybe:
> 
> $u = trim($_POST['usr']);
> $p = trim($_POST['pwd']);
> 
> $lines = file('/you/pwd/file');
> $users = array();
> foreach ($lines as $line) {
> 	list($usr, $pwd) = explode(',',$line);
> 	$users[ $usr ] = $pwd;
> }
> 
> if (isset($users[ $u ]) && ($users[ $u ] === $p)) {
> 	echo "Found {$u}, and password is correct.";
> }

That works very well.
Thanks Jochem.
Eoghan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux