因此,每当我登录并且密码正确时,它都会说密码不正确。我将如何解决这个问题
<?php
session_start();
require "php/dbc.php";
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$enc_password = md5($password);
if ($username && $password) {
$query = mysql_query("SELECT * FROM login WHERE username='$username'");
$numrow = mysql_num_rows($query);
if ($numrow != 0) {
while ($row = mysql_fetch_assoc($query)) {
$db_username = $row['username'];
$enc_password = $row['password'];
}
if ($username == $db_username && $enc_password == $db_password) {
//echo "Logged in <a href='members.php'>Click here to enter the members area</a>";
$_SESSION['username'] = $db_username;
header("location: members.php");
} else {
header("location: top_nav.html?error=Incorrect Password");
}
} else {
header("location: top_nav.html?error=That user doesn't exist");
}
} else {
header("location: top_nav.html?error=All fields are required");
}
?>