Header("location: insert.php"); not working


header(“location: insert.php”); not working line no 41 on index.php


I am not able to redirect to
password: *****

/* Main page with two forms: sign up and log in */

require 'util/db.php';
require 'util/utility.php';


if ($_SESSION['logged_in'] == 1)
    if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['insert'])) { //user logging in

        $firstName = $con->escape_string($_GET['firstName']);
        $lastName = $con->escape_string($_GET['lastName']);
        //echo $firstName;
        //echo $lastName;
        $result = $con->query("insert into users(first_name,last_name)values('$firstName','$lastName')");
        if ( $result == 1){ // User doesn't exist
        else { // User exists
            $message="Technical error occurred";
            //echo "hi".validatePage();
        header("location: error.php");

<!DOCTYPE html>
  <title>Sign-Up/Login Form</title>
  <?php include 'css/css.html'; ?>
  <div class="form">
      <ul class="tab-group">
        <li class="tab"><a href="#signup">Sign Up</a></li>
        <li class="tab active"><a href="#login">Log In</a></li>
      <div class="tab-content">

         <div id="login">   
          <?= $message ?>
          <form action="insert.php" method="get" autocomplete="off">
            <div class="field-wrap">
              firstName<span class="req">*</span>
            <input type="text" required autocomplete="off" name="firstName" value="<?=$firstName ?>"/>
            <?php echo $firstNameErr;?>
          <div class="field-wrap">
              lastName<span class="req">*</span>
            <input type="text" required autocomplete="off" name="lastName" value="<?=$lastName ?>"/>
          if ($submit != "true") {
          echo "<button class='button button-block' name='insert' />Submit</button>";

      </div><!-- tab-content -->
</div> <!-- /form -->
      <?php include 'commonImports/commonImports.html' ?>
    <script src="js/index.js"></script>



Are you trying to redirect index.php to insert.php??? Check your database configuration & insert.php page.