Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- if ($pass==$pass2) check not working as expected


oilyflutesalad - 12:01 pm on Nov 23, 2008 (gmt 0)


I've spent the last few hours writing a login script for my website, but I've been stumped on a problem verifying passwords...

When a user registers, their information is stored in a database. On the login page they enter the username and password, which is then checked against the information held in the database before setting a cookie. Passwords are stored base64 encoded.

Here's the code I'm having problems with:


$pass = $_POST['pass'];
$pass = strip_tags($pass);
$pass = stripslashes($pass);
$pass = mysql_real_escape_string($pass);
$pass = base64_encode($pass);
$pass2 = $array['password'];
if ($pass == $pass2)
{
echo "password matches";
}
else
{
echo "password doesn't match";
}

Later on in the script, for testing purposes, I echoed both $pass and $pass2, and they match up fine. However the script still says the passwords don't match...

Any ideas? This has been baffling me for hours! Thanks for your help.


Thread source:: http://www.webmasterworld.com/php/3792412.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com