These are my codes:
<?php
// Check connection
if ($conn->connect_error) {
$error = "Wrong Username and Password!";
$_COOKIE['err']=$error;
echo '<script language="javascript">';
echo 'alert("Wrong username or Password")';
echo '</script>';
header("Location: HomePage.php");
}else{
echo "Connected successfully";
$chckSelect ="SELECT DISTINCT intUsrType FROM trial1232016.tblUser WHERE strUsrName = '".$username."';";
$result = $conn->query($chckSelect);
if($result->num_rows > 0){
echo "ends here!";
}
?>
The question is: why does this code, do not generate the alert Wrong username or password. It just redirect to the HomePage.php which is the header...Why does it direct there in an instant without showing the wrong username or password? Can anyone help me?