I know the first thing everyone is going to say is that this has been posted hundreds of times; however, I have tried all the different methods people have suggested with still no luck... I am trying to get an alert message to popup if the login fails but for some reason the message does not want to appear. Here's what I have so far:
if($conn) {
    $result=sqlsrv_query($conn, "SELECT * FROM Operator
    WHERE Username='{$_POST['login']}'");
    $pass=sqlsrv_fetch_array($result);
    if($pass["Password"] === $_POST['password']) {
        session_start();
        $_SESSION['loggedin']=true;
        header("Location: home.php");
        exit;
    }
    else {
        header("Location: login.php");
        echo '<script type="text/javascript">';
        echo 'alert("Password Invalid!")';
        echo '</script>';
    }
}
sqlsrv_close($conn);
The php is working fine but for some reason I can't get the javascript to work. Any ideas?
 
     
     
     
     
    