I'm trying to prevent direct access to a the following file (and only allow access to those who submitted a form), but when I go right to this file, Instead of 404 I'm seeing the file correctly. Can someone tell what is wrong with this code?
<?php
  if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header("HTTP/1.0 404 Not Found");
  } else {
    if(isset($_POST['a'])){
      switch ($_POST['a']){
        case "1":
          $var = "hey";
          break;
        case "2":
          $var = "now";
          break;
        default:
          $var = "other";
      }
    }
  }
?>  
<!doctype html>
<html>
  <head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    something
  </body>
</html>
 
     
     
    