title: PHP Validation. It won't go to display page
body: <p>I'm new to PHP and the validation. I have been asked by my lecturer to make a form with session and validation.I have 3 php pages such as <code>pbt1.php , pbt2.php and validation.php</code> After all validated, it will go to display page. However, it seems like it only stopped at validation page [<code>validation.php</code>]. I need someone to check if my codes are correct or wrong too.
  <code>pbt1.php</code></p>
  <pre><code>session_start();
  ?&gt;
  &lt;html&gt;
  &lt;?php
  
  if(isset($_SESSION['pbt1']))
  {
      $nameError      =   $_SESSION['pbt1']['nameError'];  
      $numberError    =   $_SESSION['pbt1']['numberError'];
      $cityError      =   $_SESSION['pbt1']['cityError'];
      $addressError   =   $_SESSION['pbt1']['addressError'];
      $zipcodeError   =   $_SESSION['pbt1']['zipcodeError'];
      $dateError      =   $_SESSION['pbt1']['dateError'];
  }
  ?&gt;
  
  &lt;style&gt;
  .registrationform 
  {
      padding: 20px;
      margin: auto;
      margin-top: 20px;
      line-height: 30px;
      width: 600px;
      border: solid 3px red;   
  }
  
  Label
  {
      width:200px;
      display:inline-block;
  }
  
  &lt;/style&gt;
  
      &lt;div class= &quot;registrationform&quot;&gt;
  
          &lt;h1&gt;ONLINE MARATHON REGISTRATION&lt;/h1&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;form name = &quot;pbt1&quot; method = &quot;post&quot; action = &quot;validation.php&quot;&gt;
          
          &lt;Label&gt;Name&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;: &lt;/Label&gt;
          &lt;input type = &quot;text&quot; name = &quot;name&quot;&gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot; &gt; &lt;?php echo isset($nameError)?$nameError :'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;Gender &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt; 
          &lt;input type = &quot;radio&quot; name = &quot;gender&quot; value = &quot;Female&quot; required&gt;Female
          &lt;input type = &quot;radio&quot; name = &quot;gender&quot; value = &quot;Male&quot; required&gt;Male
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;Date Of Birth &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt; 
          &lt;input type = &quot;date&quot; name = &quot;date&quot;&gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot;&gt;&lt;?php echo isset($dateError)?$dateError:'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;Contact Number &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt; 
          &lt;input type = &quot;text&quot; name = &quot;phonenumber&quot;&gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot;&gt;&lt;?php echo isset($numberError)?$numberError:'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;Address &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt;
          &lt;input type = &quot;text&quot; name = &quot;address&quot; &gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot;&gt;&lt;?php echo isset($addressError)?$addressError :'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;City &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt; 
          &lt;input type = &quot;text&quot; name = &quot;city&quot; &gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot;&gt;&lt;?php echo isset($cityError)?$cityError:'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;Label&gt;Zip Code &lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;:&lt;/Label&gt; 
          &lt;input type = &quot;text&quot; name = &quot;zipcode&quot; &gt;
          &lt;span id = &quot;warning&quot; style=&quot;color: red;&quot;&gt;&lt;?php echo isset($zipcodeError)?$zipcodeError:'';?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;div style=&quot;text-align:center;&quot;&gt;
          &lt;input type = &quot;submit&quot; value = &quot;Submit&quot; name=&quot;Submit&quot;&gt;
          &lt;/div&gt;
          &lt;/form&gt;
          
      &lt;/div&gt;
  
      &lt;br&gt;&lt;br&gt;
  &lt;/html&gt;
  </code></pre>
  <p><code>pbt2.php</code></p>
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  &lt;html&gt;
  &lt;style&gt;
      table 
  {
      text-align:center;
  }
  &lt;/style&gt;
  
  
  
  &lt;div style=&quot;background-color:cyan;&quot;&gt;
  
  &lt;h1 align = 'center'&gt; YOUR INFORMATION AS THE TABLE BELOW &lt;/h1&gt;
  
  &lt;table width = '400' border = '1' align = 'center'&gt;
      &lt;tr&gt;
          &lt;td&gt;Name&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['name'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Phone Number&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['phonenumber'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Address&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['address'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;City&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['city'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Zip Code&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['zipcode'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Gender&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['gender'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Date&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['Userdata']['date'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  <p><code>validation.php</code></p>
  <pre><code>&lt;?php
  session_start();
  
  if(isset($_POST['Submit']))
  {
  
      $name = $_POST['name'];
      if(isset($name) &amp;&amp; empty($name))
      {
          $_SESSION['pbt1']['nameError']=&quot;Name must be required!&quot;;
          header('location:pbt1.php');  
          
      }
      else
      {
          if(!preg_match(&quot;/^[a-zA-Z ]*$/&quot;,$name))
          {
              $_SESSION['pbt1']['nameError'] = &quot;Only letters and white space allowed&quot;;
              header('location:pbt1.php');  
              
          }   
      }
  
      $phonenumber = $_POST['phonenumber'];
      if(isset($phonenumber) &amp;&amp; empty($phonenumber))
          {
              $_SESSION['pbt1']['numberError'] = &quot;Error, insert phone number&quot;;
              header('location:pbt1.php');  
              
          }
      else 
          {
              if(!preg_match('/^([0-9]*)$/', $phonenumber))
              {
                  $_SESSION['pbt1']['numberError'] = &quot;Numbers only&quot;;
                  header('location:pbt1.php');  
                  
              }
          }
      
      $address = $_POST['address'];
      if(isset($address) &amp;&amp; empty($address))
      {
          $_SESSION['pbt1']['addressError'] = &quot;Error, enter your address&quot;;
          header('location:pbt1.php');
          
      }
  
      $city = $_POST['city'];
      if(isset($city) &amp;&amp; empty($city))
      {
          $_SESSION['pbt1']['cityError'] = &quot;Error, enter your city&quot;;
          header('location:pbt1.php');
          
      }
  
      $zipcode = $_POST['zipcode'];
      if(isset($zipcode) &amp;&amp; empty($zipcode))
      {
          $_SESSION['pbt1']['zipcodeError'] = &quot;Error, enter your zipcode&quot;;
          header('location:pbt1.php');
          
      }
      else 
      {
          if(!preg_match('/^([0-9]*)$/', $zipcode))
          {
              $_SESSION['pbt1']['zipcodeError'] = &quot;Numbers only&quot;;
              header('location:pbt1.php');  
              
          }
      }
  
      $gender = $_POST['gender'];
  
      $date = $_POST['date'];
      if(isset($date) &amp;&amp; empty($date))
      {
          $_SESSION['pbt1']['dateError'] = &quot;Error, select the date&quot;;
          header('location:pbt1.php');
      }
  
      $_SESSION['Userdata'] = ['name'=&gt;$name ,'phonenumber'=&gt;$phonenumber,'address'=&gt;$address,'city'=&gt;$city,
                              'zipcode'=&gt;$zipcode,'gender'=&gt;$gender,'date'=&gt;$date ];
  
  }
  
  function test_input($data)
  {
      $data = trim($data);
      $data = stripslashes($data);
      $data = htmlspecialchars($data);
      return $data;
  }
  
  if($_SESSION['pbt1']['nameError'] == &quot;&quot; &amp;&amp; $_SESSION['pbt1']['numberError'] == &quot;&quot; &amp;&amp; $_SESSION['pbt1']['addressError']== &quot;&quot; &amp;&amp; $_SESSION['pbt1']['cityError']==&quot;&quot; &amp;&amp; $_SESSION['pbt1']['zipcodeError']==&quot;&quot; &amp;&amp; $_SESSION['pbt1']['dateError']==&quot;&quot;)
      {
      header(&quot;location:pbt2.php&quot;);
      exit; }
  ?&gt;
  </code></pre>