title: PHP IP Whitelist
body: <p>When i try to execute the code below it just doesn't redirect like it should be because my ip isn't equal to those. Not sure what i'm doing wrong here.</p>
  
  <pre><code>&lt;?php
      $whitelist = array('111.111.111.112', '111.111.111.112');
      if (in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
          //Action for allowed IP Addresses
      } else {
          header("Location: http://www.redirect.to.url.com/");
      }
      echo $_SERVER['REMOTE_ADDR'];
  ?&gt;
  &lt;html&gt;
     &lt;body&gt;
        &lt;form action = "upload.php" method = "POST" enctype = "multipart/form-data"&gt;
           &lt;input type = "file" name = "image" /&gt;
           &lt;input type = "submit"/&gt;   
        &lt;/form&gt;
  
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>