<?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');
}
?>
When i go to admin.php?action=login and i try to log in, i get send to the form again?
Help please!
Greetings
PHP’s string comparisons are case-sensitive, and REQUEST_METHOD is all-capitals: ‘POST’ or ‘GET’, never ‘post’ or ‘get’.