-1
當我嘗試在我的頁面上登錄時,它已成功連接,但當頁面重新加載時,我將重定向回到我的登錄頁面,有人可以幫助我嗎?PHP重定向 - 登錄錯誤
<?php
session_start();
$user["beta"] = "beta01key";
if(!isset($_SESSION['ingelogd']))
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (empty($_POST['username']) || empty($_POST['password']))
{
exit('<br /><br /><html><body><div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Please fill in all fields!</span></div><meta http-equiv="refresh" content="1"></body>');
}
elseif ($user[$_POST['username']] != $_POST['password'])
{
exit('<br /><br /><div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Your username/password is wrong!</span></div><meta http-equiv="refresh" content="1"></body>');
}
else
{ if (!isset($_SESSION['ingelogd']))
echo '</body><div id="center"><h2> Login Status: <br/></h2><span style="color:green; font-weight: bold">You are now logged in!</span></div></body></head>';
}
}
else
{
exit('<br /><br />
<link rel="stylesheet" href="/css/body.css">
<link rel="stylesheet" href="/css/button.css">
<div id="center">
<form method="POST" action=""><p>
Username:<br />
<input type="text" name="username" /><br /><br />
Password:<br />
<input type="password" name="password" /><br /><br />
<input type="submit" value="Login" /> <input type="reset" value="Empty fields" />
</form></div>');
}
}
?>
<link rel="stylesheet" href="/css/body.css">