title: PHP redirect after inserting data
body: <p>I'm having issues on redirecting to another page after inserting data.</p>
  
  <p>I'm working on localhost i'm trying to redirect into another page (url) after insertin data.</p>
  
  <p>With the code below, I try putting google url it doesn't redirect it stays on the page after submission.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  /**
   * Template Name: Booking Template
   */
  get_header();
  
  require_once("db.php");
  
  if(count($_POST)&gt;0) {
  $sql = "INSERT INTO bookings (reason, doctor, bookingDate, bookingTime, patientName, gender, phone, email) VALUES ('" . $_POST["reason"] . "','" . $_POST["doctor"] . "','" . $_POST["bookingDate"] . "','" . $_POST["bookingTime"] . "','" . $_POST["patientName"] . "','" . $_POST["gender"] . "','" . $_POST["phone"] . "','" . $_POST["email"] . "')";
  
    if(mysqli_query($link, $sql)){
      echo "Records inserted successfully.";
      header("location: http://www.google.com"); 
  } else{
      echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
  }
  }
  mysqli_close($link);
  ?&gt;</code></pre>
  </div>
  </div>
  </p>