The page refreshes instead of going to index.php. The header function seems to be not working, even if I move it anywhere in the code. Does anyone know why this is happening? Would be thankful for the help!
<?php
if (isset($_POST['btnLogin'])) {
    $Email = $_POST['email'];
    $Password = $_POST['password'];
    $Email = mysqli_real_escape_string($connection, $Email);
    $Password = mysqli_real_escape_string($connection,$Password);
    $query ="SELECT * FROM users WHERE Email = '{$Email}'";
    $select_customer_query = mysqli_query($connection, $query);
    if(!select_customer_query) {
        die("QUERY FAILED". mysqli_error($connection));
    }
    while($row = mysqli_fetch_array($select_customer_query)) {
        $stored_Email = $row['Email'];
        $stored_Password = $row['Password'];
        $User_ID = $row['User_ID'];
        $string ="Logged in as";
        $logoutlink = '/ <a href="resources/includes/back/logout.php">Logout</a>';
        $Firstname_db = $row['First_Name'];
        $Lastname_db = $row['Last_Name'];
        $role_db = $row['Role'];
    } 
    if (password_verify($Password,$stored_Password) ) {
        $_SESSION['FirstName'] = $Firstname_db;
        $_SESSION['LastName'] = $Lastname_db;
        $_SESSION['Email'] = $stored_Email;
        $_SESSION['string'] = $string;
        $_SESSION['logoutlink'] = $logoutlink;
        $_SESSION['User_ID'] = $User_ID;
        $_SESSION['Role'] = $role_db;
        echo '<div class="alert alert-success alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> Your Email and Password was correct.  Click this link to go to <a href="index.php"> Home </a> </div> ';
    } else {
        if ($Email == $stored_Email && $Password !== $stored_Password) {
            echo '<div class="alert alert-danger alert-dismissible" role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <strong>Warning!</strong> Your Password Was Incorrect. Please Try Again. </div> ';
        }
    }  
    if ($Email !== $stored_Email && $Password !== $stored_Password) {
        echo '<div class="alert alert-danger alert-dismissible" role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <strong>Warning!</strong> Your Email or Password Was Incorrect. Please Try Again. </div> ';
    } 
    header('Location: index.php');
}
?>
 
    