所以我无法弄清楚我的PHP出了什么问题导致了这个问题。正如您从代码中看到的那样,我根据if语句对其进行了回显。如果细节等于查询,那么它将回显它所做的Test2。但为什么它没有重定向?我无法弄清楚出了什么问题。
<?php
include "../inc/db.php";
include "../inc/functions.php";
$tip = "";
if(isset($_POST["submit"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$username = mysqli_real_escape_string($connection, $username);
$password = mysqli_real_escape_string($connection, $password);
$query = "SELECT * FROM users WHERE username = '{$username}' ";
$select_user_query = mysqli_query($connection, $query);
if(!$select_user_query) {
die("Query failed. Reason: " . mysqli_error($connection));
}
while($row = mysqli_fetch_array($select_user_query)) {
$db_user_id = $row['id'];
$db_username = $row['username'];
$db_password = $row['password'];
}
if($username !== $db_username && $password !== $db_password ) {
header("Location index.php");
$tip = "Incorrect details!";
echo "Test1";
} elseif ($username == $db_username && $password == $db_password) {
header("Location ");
echo "Test2";
} else {
header("Location index.php");
echo "Test3";
}
}
?>
但是我在while循环中定义了变量
答案 0 :(得分:0)
header("Location dashboard.php");
缺少半结肠
header("Location: dashboard.php");
我很蠢......