Code:
if($_SERVER["REQUEST_METHOD"] == "POST"){
$queryCommand = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
$res1 = mysqli_query($connection, queryCommand);
if ($res1 == FALSE && (empty(trim($_POST["username"])) || empty(trim($_POST["password"])))){
$errorTxt = "Username or Password is incorrect!";
} else {
if ($res1 == FALSE) {
$errorTxt = "Username or Password is incorrect!";
} elseif ($res1 != FALSE) {
session_start();
$_SESSION["loggedin"] = true;
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
header("location: index.php");
}
}
}
When I refresh the page, it somewhy writes "Username or Password is incorrect!" to the HTML paragraph ( <h4 id="logErrText"><?php echo $errorTxt;?></h4> ). Help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire