Display message "incorrect login or password"

isimienne Posted messages 124 Status Member -  
MickaToast Posted messages 162 Status Member -
Hello,
please is there anyone who can help me I would like to display a message "incorrect login or password!"
here is my code
but it gives me an error when I add this echo message.

<?php
session_start();
#see if user is logged in
if (isset($_POST["login"])){
if (isset($_POST["n"]) && ($_POST["n"] == "test" ) && isset($_POST["m"]) &&($_POST["m"] == "test" ))
{
$_SESSION["Authenticated"]= 1;
}
else {
$_SESSION["Authenticated"]= 0 ;
header("Location: index.html");
echo " incorrect login or password! ";

}
session_write_close();
header("Location: index.php");
}
// user is logging out
if (isset($_GET["logout"])) {
session_destroy();
header("Location: index.html");
}

?>

and thanks in advance

Configuration: Windows 7 / Chrome 35.0.1916.114

1 answer

MickaToast Posted messages 162 Status Member 24
 
$_SESSION["Authenticated"]= 0 ; header("Location: index.html"); echo " login or password incorrect! "; 


the header() function immediately redirects to the target, no lines of code will be executed after this function. If you want to display a message on index.php, we can imagine this:

header("Location: index.php?Authentification=Error");


Just check on index.php if $_GET["Authentication"] is present and equals "Error", in this case, the credentials are incorrect.

I hope this help is important to you!
Have a good evening!
2