title: PHP URL redirection not working as expected
body: <p>I am having a problem loading a fresh "thankyou.php" file after a form has been submitted. The form sends data to itself and if all the data passes validation it then proceeds to save them in the database.</p>
  
  <p>The "thankyou.php" quite loads but the "signup.php" still remains and the output of both files remain in the same page. I want it on a fresh page but it won't work. </p>
  
  <p>Here is my sanitation:</p>
  
  <pre><code>if ($_SERVER["REQUEST_METHOD"] == "POST")
  {
  if (empty($_POST["firstName"]))
  {$Err[] = "* First Name is required";}
  else
  {
  $name = test_input($_POST["firstName"]);
  // check if name only contains letters and whitespace
  if (!preg_match("/^[a-zA-Z ]*$/",$name))
    {
    $Err[] = "Only letters are allowed in First Name"; 
    }
  }
  
  if (empty($_POST["email"]))
  {$Err[] = "* Email is required";}
  else
  {
  $email = test_input($_POST["email"]);
  // check if e-mail address syntax is valid
  if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
    {
    $Err[] = "Invalid email format"; 
    }
  }   
  }
  </code></pre>
  
  <p>And the form:</p>
  
  <pre><code>&lt;div id = "signupform"&gt;
  </code></pre>
  
  <p>" >
      
       
        Email Address 
      
       
        First Name <br/>
      
      
      
      </p>
  
  <p>And database connection and insertion:</p>
  
  <pre><code>try {
    $conn = new PDO('mysql:host=localhost; dbname=mydb', 'root', ''); 
    $conn-&gt;setAttribute(PDO:: ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  }
  </code></pre>
  
  <p>catch(PDOException $pe) {
        echo('Connection error, because: ' .$pe->getMessage());
      }</p>
  
  <p>//Insert data to Database if values are not empty and sanitized
    if (!empty($_POST["firstName"]) &amp;&amp; !empty($_POST["email"]))
    {
      $qry = "INSERT INTO userdetails (email, firstName) values (?, ?)";</p>
  
  <pre><code>$q = $conn-&gt;prepare($qry) or die("ERROR: " . implode(":", $conn-&gt;errorInfo()));
  
  $q-&gt;bindParam(1, $email);
  $q-&gt;bindParam(2, $firstName);
  
  
  try {
    if($q-&gt;execute()){
      header("Location: invoice.php");
      exit;
    }
    }
  catch(PDOException $pe) {
    echo('Connection error, because: ' .$pe-&gt;getMessage());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And that's all but it is still not loading a fresh page.</p>