title: Redirect to the next page after clicking on submit button php mysql
body: <p>I would like to redirect to the next page after clicking on the submit page, but I get the following error: </p>
  
  <blockquote>
    <p>Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\forms\P_details.php:80) in C:\xampp\htdocs\P_details.php on line 70</p>
  </blockquote>
  
  <p>the following is the php code on P_details.php</p>
  
  <blockquote>
    <p>
  </blockquote>
  
  <pre><code>//connect to connect to the database and initialize all functions
  include 'scripts/functions/init.php';
  include 'html/head.php';
  include 'html/page_title.php';
  include 'html/top_menu.php';
  include 'titles/P_details.php';
  
  //Generate a random Personid
  $Personid = rand(1,9999999);
  $_SESSION['Personid'] = $Personid;
  //Carry over the Jobid to this page
  $Jobid = $_SESSION['SESS_MEMBER_JOB'];
  
  if(empty($_POST)=== false)
      {
          $R_fields = array('Title','Surname','Forename','IdentityNumber','Gender','Race','Nationality');
          foreach($_POST as $key=&gt;$value)
          {
              if (empty($value) &amp;&amp; in_array($key,$R_fields)=== true)
                  {
                      $errors[] = 'fields marked with (*) are required';
                      break 1;
                  }
          }
  
          if(empty($errors)=== true)
              {
  
                  if($_POST['title'] == '-Select-')
                      {
                          $errors[] ='Please select Title';
                      }
                  if($_POST['Gender'] == '-Select-')
                      {
                          $errors[] ='Please select Gender';
                      }
                  if($_POST['Race'] == '-Select-')
                      {
                          $errors[] ='Please select Race';
                      }
                  if($_POST['Nationality'] == '-Select-')
                      {
                          $errors[] ='Please select Nationality';
                      }
  
              }
  
      }
  
      include 'forms/P_details.php';
  
      if(empty($_POST) === false &amp;&amp; empty($errors)=== true)
          {
              //submit personal details
              $personal_details = array(
              'Personid'=&gt;$Personid,
              'Title' =&gt; $_POST['title'],
              'Surname'=&gt;$_POST['Surname'],
              'Forename' =&gt; $_POST['Forename'],
              'IdentityNumber'=&gt;$_POST['IdentityNumber'],                                             
              'Gender'=&gt;$_POST['Gender'],
              'Race'=&gt;$_POST['Race'],
              'Nationality'=&gt;$_POST['Nationality'],
              'WorkPermitNumber'=&gt;$_POST['WorkPermitNumber'],
              'JobID'=&gt;$Jobid);                       
              personal_details($personal_details);                        
              //redirect
              header('Location:Address_insert.php');
              exit();                                                                                                                             
          }
      else if(empty($errors) === false)
          {
              //output errors if the errors array is not empty
              echo output($errors);
          }
  </code></pre>
  
  <p>?></p>
  
  <p>Please assist</p>