继承我的剧本,无论我做什么,我都会收到不正确的密码,请帮忙!
<?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");
?>
答案 0 :(得分:3)
$dbemail = $row['email'];
$dbemail = $row['password'];
你把这两个叫做dbemail。在if语句中,使用$ dbusername和$ md5password。
您应该将$ row ['email']更改为$ dbusername,将$ row ['password']更改为$ md5password。
$dbusername = $row['email'];
$md5password = $row['password'];
答案 1 :(得分:0)
您从未定义$dbusername
或$password
。
答案 2 :(得分:0)
你要分配dbemail两次而不是md5password。