I'm trying to prevent direct access to a the following file (and only allow access to those who submitted a form), Can someone tell what is wrong with this code?
<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('HTTP/1.0 405 Method Not Allowed');
} else {
if(isset($_POST['a'])){
switch ($_POST['a']) {
case "1":
$var = "hey";
break;
case "2":
$var = "now";
break;
default:
$var = "other";
}
}
?>