title: Form data lost between pages
body: <p>I am struggling to understand the session() command, even after reading numerous pages about it.</p>
  
  <p>I cannot get data from the form to appear on a subsequent page</p>
  
  <p>Here are two very simplified versions of my pages, can someone explain what is missing please</p>
  
  <hr>
  
  <p>"submitform.php" ...</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
  &lt;title&gt;Submit Form&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php
  session_start();
  $_SESSION['name']=$_POST['name'];
  $_SESSION['email']=$_POST['email'];
  
  
  if ($_SERVER["REQUEST_METHOD"] == "POST")
  {
  header('Location: displayform.php');
  }
  
  
  ?&gt;
  
  &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;
  Name &lt;input type="text" name="name"/&gt;&lt;br/&gt;
  Email address &lt;input type="text" name="email"/&gt;&lt;br/&gt;
  &lt;input class="submit" type="submit" name="submit" value="SUBMIT"/&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>"displayform.php" ...</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
  &lt;title&gt;Display Form&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php
  session_start();
  $_SESSION['name']=$_POST['name'];
  $_SESSION['email']=$_POST['email'];
  
  $name = $_SESSION['name'];
  $email = $_SESSION['email'];
  
  echo "Name: " . $name . "&lt;br&gt;";
  echo "Email: " . $email;
  
  
  ?&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>