title: Redirect to another page after confirm and post values
body: <p>I have 2 php files. One of them has values for the variables and the other uses those values. I am using <strong>post</strong> to pass value from one file to another.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;&lt;body&gt;
  &lt;form method="POST"&gt;
      &lt;input type="hidden" name="firstname" value="Saurabh"&gt;
      &lt;input type="hidden" name="age" value="22"&gt;
   &lt;input type="submit" onclick="javascript:completeAndRedirect();"&gt;
  &lt;/form&gt;
  &lt;script&gt;
  function completeAndRedirect(){
   var r = confirm("Press a button!");
      if (r == true) {
          location.href='page2.php';
      }
   }
  &lt;/script&gt;
  &lt;/body&gt;&lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  //Using POST
  $firstname = $_POST['firstname'];
  $age = $_POST['age'];
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;
  first name : &lt;?php echo "$firstname"; ?&gt; &lt;br&gt;
  age :   &lt;?php echo "$age"; ?&gt; 
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But it isn't working the way i want it to work.
  It should redirect only when "ok" is clicked<br>IT DOES NOT REDIRECT ANYWHERE.</p>