Verifying encrypted password from MySQL database with PHP
| From: | Chinmoy Barua | Date: | Thu, 06 Mar 2003 05:21:05 +0000 |
| Subject: | Verifying encrypted password from MySQL database with PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138414@lists.php.net to get a copy of this message | ||
Hello,
I have an user table where the username and passwords of the users are stored. The passwords are
stored in encrypted format (the MySQL function 'ENCRYPT($password) is used for insertation).
Now I want to varify username and password. For that, I have written the followin PHP code:
---------------------------------------------------------------------------------------------
N.B.: " $flogin " is a veriable which store username from a HTML form. &
"$fpass " is a veriable which store password from a HTML form.
$query="SELECT UserName, Attribute, Value FROM radcheck WHERE UserName='$flogin
$result=mysql_db_query("$dbB","$query");
$row=mysql_fetch_array($result);
echo mysql_error();
$username=$row[0];
$attribute=$row[1];
$value=$row[2];
$salt = substr("$row[2]", 0, CRYPT_SALT_LENGTH);
$passwordc = crypt("$fpass",$salt);
------------------------------------------------------------------------------------------------
By this, I can verify the first eight charectar. If my password is more than eight charectar, than
it checks only first 8 charecter.
How can I solve this problem?
- Chinmoy
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more