0

这是我的脚本,无论我做什么,我都会收到错误的密码,请帮助!

<?php

$email = $_POST['email-field'];
$password = $_POST['password-field'];

if ($email&&$password){ 
   $connect = mysql_connect("xx","xx","xx") or die("Couldnt connect!");
   mysql_select_db(xx) or die("Couldnt find db");

   $query = mysql_query("SELECT * FROM users WHERE email='$email'");
   $numrows = mysql_num_rows($query); 
   if ($numrows!=0){
     while ($row = mysql_fetch_assoc($query)){
        $dbemail = $row['email'];
        $dbemail = $row['password'];
     }

  if ($username==$dbusername&&$md5password==md5($password)) {
      echo "You're in!";
  }else
      echo "Incorrect password";    
}
else
    die("That user doessnt exist!");
}
else
    die("Please enter a username and a password"); 

?>
4

3 回答 3

3
$dbemail = $row['email'];
$dbemail = $row['password'];

你把这两个都称为$dbemail。在 if 语句中,您使用 $dbusername 和 $md5password。

您应该将 $row['email'] 更改为 $dbusername 并将 $row['password'] 更改为 $md5password。

$dbusername = $row['email'];
$md5password = $row['password'];
于 2012-06-07T00:42:15.140 回答
0

你从来没有定义$dbusername也没有$password

于 2012-06-07T00:42:33.517 回答
0

您分配 dbemail 两次而不是 md5password。

于 2012-06-07T00:43:34.663 回答