这是一个登录验证页面,一旦它验证了用户的详细信息我希望它指示用户在“account.php”页面,所有验证工作正常,但用户只是不会重定向到帐户页面。PHP尝试发送成功消息,然后将用户重定向到另一页
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if($_SESSION['loggedin'] = true) {
session_destroy();
}
if(empty($username) || empty($password)) {
echo("ERROR|Please fill out all of the fields.");
} else {
$file = fopen("Users.csv","r");
while(! feof($file)) {
$rows = fgetcsv($file);
if (($rows[1] == $username) && ($rows[4] == $password)) {
session_start();
$_SESSION['loggedin'] = true;
$_SESSION["username"] = $rows[1];
$_SESSION["email"] = $rows[2];
$_SESSION["dateOfBirth"] = $rows[3];
$_SESSION["password"] = $rows[4];
$_SESSION["userScore"] = $rows[5];
echo("SUCCESS|Logging In as " . $username);
header('Location: ../account.php');
exit();
}
}
echo("ERROR|Incorrect Username or Password.");
fclose($file);
}
?>
它仍然不重定向我虽然 – 2014-12-03 11:52:26
为了澄清,使用标题您已经发送了一些内容到浏览器后,你不能重定向。如果你确实希望他们看到消息然后被重定向,你可以在html的头部输出一个元刷新标签,如下所示:''但老实说,用户不需要看到那个页面,并且会用来立即登录 – 2014-12-03 11:52:35
通常,如果你修复这两个,它应该可以工作。 – Pupil 2014-12-03 11:53:20