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


#1

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

https://nike119.000webhostapp.com/index.php

I am not able to redirect to
https://nike119.000webhostapp.com/insert.php
username:nitesh.shetty@mindgate.in
password: *****

<?php 
/* Main page with two forms: sign up and log in */
session_start();

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

$message="";
$firstName="";
$lastName="";
$firstNameErr="";
$lastNameErr="";
$submit="";
$validateFlag=false;

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
            $submit="true";
            $message="Success";
    
        }
        else { // User exists
            $message="Technical error occurred";
        
        }
        }else{
            //echo "hi".validatePage();
        }
        
    }else{
        header("location: error.php");
    }


?>
<!DOCTYPE html>
<html>
<head>
  <title>Sign-Up/Login Form</title>
  <?php include 'css/css.html'; ?>
</head>
<body>
  <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>
      </ul>
    
        
      <div class="tab-content">

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

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

</body>
</html>

#2

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