title: Restrict direct page access
body: <p>In attempt of securing an administrator area of a site I'm working on I made an index.php which contains </p>
  
  <pre><code>if (isset($_POST['password']) &amp;&amp; isset($_POST['userName'])) {
          if($_POST['password']==$pass &amp;&amp; $_POST['userName']==$username)
          {
              header( 'Location: admin.php' ) ;
          }
  </code></pre>
  
  <p>This redirects to a file in the same folder called admin.php. The problem is that I can access this file if I write <code>localhost/folder/admin.php</code>. Please tell me how to restrict the direct access to this page. The only way accesing it should be from index.php after username and password.</p>