eching md5 hashtag值

时间:2014-03-21 04:11:56

标签: php mysql

我的数据库中有用户密码,这些密码以md5 hashtag格式输入。现在,当我尝试回显用户的密码时,输出的值与数据库中的md5 hashtag值不同。
例如:数据库中的密码是0cc175b9c0f1b6a831c399e269772661 密码echo'd out下面是dc0ae7e1387be9​​b795f5d6299e383759

$select=queryMysql("SELECT * FROM members WHERE user='$user'"); 
$fetch=mysql_fetch_array($select);
$password=$fetch['password'];

echo $password;

我正在创建密码更改表单(即用户可以更改密码的表单),并且需要用户在创建新密码之前验证他们是否知道当前密码。

这是用户注册时密码的创建方式:

if (isset($_POST['user']))
{
    $user = trim(sanitizeString($_POST['user']));
    $pass = trim(sanitizeString($_POST['pass']));
    $pass_hash = md5(sanitizeString($_POST['pass']));

    $mydomain = trim(substr($user, strrpos($user, '@') + 1));
    if ($user == "" || $pass == "" )
        $error = "Not all fields were entered<br /><br />";
    else
    {
        if (mysql_num_rows(queryMysql("SELECT * FROM members
              WHERE user='$user'")))
            $error = "That username already exists<br /><br />";
        else
          {
            queryMysql("INSERT INTO members VALUES('$user', '$pass_hash', '$mydomain')");
            die("<h4>Account created</h4>Please log in.<br /><br />");
        }
    }
}

0 个答案:

没有答案