As the title suggests I am trying to use the same .php page and have it display something new upon being redirected from a particular location.
In context... I have a login which upon successful login redirects to a home page but if unsuccessful, redirects to the index. Is there a way that I can tell my index page to display an "Error logging in" message when it has been redirected from my login page?
Here is my login code...
<?php
session_start();
include('conn.php');
$query = "SELECT * FROM User";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
if (isset($_POST["submit"])) {
    $logEmail = $conn->real_escape_string($_POST['logEmail']);
    $logPass = $conn->real_escape_string($_POST['logPass']);
    $checkuser = "SELECT * FROM User WHERE Email='$logEmail' AND UserPassword=AES_ENCRYPT('$logPass', 'MyKey')";
    $userresult = mysqli_query($conn, $checkuser) or die(mysqli_error($conn));
    $loginsucc = (mysqli_num_rows($userresult) > 0);
    if (mysqli_num_rows($userresult) > 0) {
        while ($row = mysqli_fetch_assoc($userresult)) {
            $userPriKey = $row['UserID'];
            $userid = $row['Email'];
            $accounttype = $row['IsAdmin'];
            $firstname = $row['FirstName'];
            $surname = $row['LastName'];
            $_SESSION['userPriKey'] = $userPriKey;
            $_SESSION['name'] = $firstname;
            $_SESSION['surname'] = $surname;
            $_SESSION['Email'] = $userid;
            $_SESSION['IsAdmin'] = $accounttype;
            if($accounttype == '1'){
                header("Location: home.php");
            }else if ($accounttype == '0'||$accounttype == NULL ) {
                header("Location: userhome.php");
            }
        }
    } else {
        header("Location: index.php");
    }
}
?>
 
     
    