title: PHP Redirect Not Working When Using Form Action to Submit to PHP Page
body: <p>So I am using this form to submit to PHP file. PHP file has a redirect header that WORKS when I call the php file directly in browser, but when it is accessed via the action attribute in the form, it does nothing. There was a time I could make it redirect without the refresh: 2, but then the issue arose that it was only including the redirected file within the php document itself, so my javascript and submit functions would fail... Weird? Please advise! What's going on?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form name="ats_routing" id="ats_routing" method="post" action="php/upload.php" enctype="multipart/form-data"&gt;
  
      &lt;!-- Some html generated by codiqa --&gt;
  
      &lt;a onclick="submitForm();" data-transition="flip" data-theme="" data-icon="check"&gt;
          Submit
      &lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Javascript part</p>
  
  <pre><code>/****CREATE JQUERY SUBMIT FUNCTION FOR IFRAME VALIDATION CHECK FOR Codiqa****/
  function submitForm() {
      if ($("#ats_routing").valid()) {
         //alert("Thank You. Your Routing Form Has Been Submitted.");
         $('#ats_routing').submit();
      }
  }
  </code></pre>
  
  <p>PHP that form redirects to (upload.php)</p>
  
  <pre><code>&lt;?php
  header("Refresh: 2; URL=/ats-routing/"); /* Redirect browser */
  
  //Parse and store the db ini file, this will return an associative array
  db_config_ats_ibutton();
  db_connect();
  
  $total_weight       = $_POST['total_weight'];
  $uf             = $_POST['number_uf'];
  
  
  $query="INSERT INTO datbasae (
      lbs_uf,
      total_weight,
      district)
  
      VALUES(
      '$uf',
      '$total_weight',
      '$district')";
  
  query_db($query);
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;title&gt;ATS Routing&lt;/title&gt;
    &lt;link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css"&gt;
  &lt;link rel="stylesheet" href="http://dev.rs.idmyasset.com/ats-routing/css/theme.css"&gt;
  &lt;!-- Extra Codiqa features --&gt;
  &lt;link rel="stylesheet" href="https://codiqa.com/view/bb40208d/css"&gt;
  &lt;!-- jQuery and jQuery Mobile --&gt;
  &lt;script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"&gt;    &lt;/script&gt;
  &lt;meta http-equiv="refresh" content="2; url=http://dev.rs.idmyasset.com/ats-routing/"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;!-- Home --&gt;
  &lt;div data-role="page" id="page1"&gt;
    &lt;div id="header" data-theme="" data-role="header"&gt;
        &lt;h3 id="header"&gt;
            ATS Routing Data
        &lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-role="content"&gt;
      &lt;h1 align="center"&gt;Thank You&lt;/h1&gt;
      &lt;h1 align="center"&gt;Your Form Has Been Submitted!&lt;/h1&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>