title: If either GET or POST are empty, redirect
body: <p>Very strange problem and I'm scratching my head. If anyone can help it would be much appreciated, thanks.</p>
  
  <p>I have a Search Location result page that should only appear if either 1) the form on the previous page has been submitted; or 2) they are searching via a url, e.g. </p>
  
  <p><code>www.mywebsite.com?use_url=on&amp;zipcode=UB95BX&amp;radius=50</code>.</p>
  
  <p>So, at the top of the page I have the following code:</p>
  
  <pre><code>// Validate input and sanitize
  if (empty($_POST['submit']) || empty($_GET['use_url']))
   {
    header('Location: index1.php');
    exit; 
   } 
  </code></pre>
  
  <p>Problem is, it's not working and it's redirecting EVERY request. Does anyone know how I can get it to work, so that if there is no submit post, or if there is no get request (basically, if the user types in <code>www.mywebsite.com/locations.php</code> directly into the url bar), the user is redirected.</p>
  
  <p>Strange thing is this, if I leave out the empty($_GET) command and make it therefore </p>
  
  <pre><code>// Validate input and sanitize
  if (empty($_POST['submit']))
   {
    header('Location: index1.php');
    exit; 
   } 
  </code></pre>
  
  <p>It works fine on an empty submit, the problems only occurs when I specify two criteria for a redirect.</p>
  
  <p>Thanks everyone / Luke</p>