<?php
if(isset($_GET['action'])){
switch ($_GET['action']) {
case 'login':
include 'header.php';
if($_SERVER['REQUEST_METHOD'] == "post"){
if(!empty($_POST['password']) && $_SERVER['REMOTE_ADDR'] == "My IP Adress" && $_POST['password'] == "Password"){
$_SESSION['AlphenWeerNladmin'] = 1;
echo 'Logged in!';
}
else
{
echo 'Wrong password or IP adress';
}
}
else
{
?>
<form action="admin.php?action=login" method="post">
<input type="password" name="password">
<input type="submit" value="submit">
</form>
<?php
}
include 'footer.php';
break;
case 'logout':
include 'header.php';
$_SESSION['AlphenWeerNladmin'] = 0;
echo 'Logged out!';
include 'footer.php';
break;
default:
header('Location: 404.php');
break;
}
}
else
{
header('Location: 404.php');
}
?>
當我去admin.php?action = login並且我嘗試登錄時,我會再次發送到窗體?管理員登錄不會登錄?
請幫忙!
問候
GET將返回查詢字符串這正是他要尋找的。我希望POST會覆蓋REQUEST_METHOD中的GET,但是誰知道。 – Kris 2011-02-18 17:12:24
`
我並不是在爭論這個事實,我只是說他的REQUEST_METHOD檢查可能不會被滿足,因爲他發送的是GET和POST變量。我不確定哪些優先於$ _SERVER ['REQUEST_METHOD']變量 – JamesHalsall 2011-02-18 17:15:37