2 回答
TA贡献1765条经验 获得超5个赞
我只是忘了标题后面的分号。
$query = "SELECT * FROM user WHERE username = '" .$username. "'";
$result = mysqli_query($conn,$query);
while ($row = mysqli_fetch_assoc($result)){
// See if the password is correct
if ($_POST["password"] === $row['password']){
echo "Logon Successful!";
header("Location: index.php");
exit();
}
TA贡献1841条经验 获得超3个赞
可能会有一些变化,如下所示:
login.php
$username = $_POST["username"];
$password = $_POST["password"];
$conn = mysqli_connect($host, $user, $pass, $db);
$query = "SELECT * FROM user WHERE username = '" . $username . "'";
$result = mysqli_query($conn,$query);
while ($row = mysqli_fetch_assoc($result)){
// See if the password is correct
if ($password === $row['password']){
header('location: login_successful.php');
}else {
// you can hide the message at QueryString via SESSION or COOKIE
header('location: login_form.php?message=FAIL_MESSAGE'); //you can detect and show login status message.
}
}
- 2 回答
- 0 关注
- 210 浏览
添加回答
举报