title: Passing PHP variable data onto another page after validation
body: <p>While I found something similar to this question on here it didn't answer my question outright.</p>
  
  <p>I have set up this php script to validate the form data, which works, after its validated I want it to then pass the info onto another script page to let the user then verify their input data and then mail the data. Its at this state that I'm having trouble. I've spent the last few days trying to find a solution to this and unfortunately coming up short.</p>
  
  <pre><code>        &lt;?php
  
              $name_error = '';
              $email_error = '';
              $comments_error = '';
  
              $error = false;
  
              if (!empty($_POST['submitted']))
                  { //if submitted, the validate.
  
                      $name = trim($_POST['name']);
  
                      if (empty($name))
                          {
                              $name_error='Name is required';
                              $error = true;
                          }
  
                      $email = trim($_POST['email']);
  
                      /* If e-mail is not valid show error message */
                      if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
                          {
                              $email_error='E-mail address not valid';
                              $error = true;
                          }
  
                      $comments = trim($_POST['comments']);
  
                      if (empty($comments))
                          {
                              $comments_error='Comments are required';
                              $error = true;
                          }
  
                      if ($error == false)
                          {
                              $name_send = $name;
                              $email_send = $email;
                              $comments_send = $comments;
  
                              /* Redirect visitor to the thank you page */
                              header('Location: /mail.php');
                              exit();
                          }
                  }
  </code></pre>
  
  <p>The form this is attached to:</p>
  
  <pre><code>&lt;form action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']);?&gt;" method="post"&gt;
  
  &lt;label&gt;Your Name&lt;/label&gt;&lt;br /&gt;
  &lt;input type="text" name="name" style="width:95%" class="text" value='&lt;?php echo htmlentities($name) ?&gt;' /&gt;
  &lt;br/&gt;
  &lt;span class='error'&gt;&lt;?php echo $name_error ?&gt;&lt;/span&gt;
  &lt;br /&gt;
  
  &lt;label&gt;Email&lt;/label&gt;&lt;br /&gt;
  &lt;input type="email" name="email" style="width:95%" class="text" value='&lt;?php echo htmlentities($email) ?&gt;' /&gt;
  &lt;br/&gt;
  &lt;span class='error'&gt;&lt;?php echo $email_error ?&gt;&lt;/span&gt;
  &lt;br /&gt;
  
  &lt;label for="comments" style="font-size:16px;"&gt;Feedback Comments&lt;/label&gt;&lt;br /&gt;
  &lt;textarea name="comments" style="width:95%;" rows="8" value='&lt;?php echo htmlentities($comments) ?&gt;'&gt;&lt;/textarea&gt;
  &lt;br /&gt;
  &lt;span class='error'&gt;&lt;?php echo $comments_error ?&gt;&lt;/span&gt;
  &lt;br /&gt;
  
  
  &lt;input type="checkbox" name="allowCommentPublish" checked="checked" /&gt;
  &lt;label for="allowCommentPublish" style="font-size:10px;"&gt;Allow these comments to be used on our website&lt;/label&gt;
  
  &lt;fieldset class="optional"&gt;
  
      &lt;h2&gt;[ OPTIONAL ]&lt;/h2&gt;
  
      &lt;label&gt;Company Name&lt;/label&gt;&lt;br /&gt;   
      &lt;input type="text" name="companyName" style="width:95%" class="text" /&gt;
      &lt;br/&gt;
  
      &lt;label&gt;Phone&lt;/label&gt;&lt;br /&gt;
  
      &lt;input type="text" name="phone" style="width:95%" class="text" /&gt;&lt;br/&gt;
  
      &lt;div style="margin:5px 0px;"&gt;
              &lt;input type="checkbox" name="incmarketing" /&gt;
              &lt;label style="font-size:10px;"&gt; Yes, you can email me specials and promotions.&lt;/label&gt;
          &lt;br/&gt;
      &lt;/div&gt;
  &lt;/fieldset&gt;
  
  &lt;fieldset&gt;
      &lt;input type="submit" name="submitted" value="Send" /&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p></p>
  
  <p>I will point out im focusing on the main data inputs: Name E-mail and comments.</p>
  
  <p>I need the info from this form to be sent onward but i dont know exactly how to do this and any help will be appreciated greatly.</p>