title: How to display error message on php login without pop up box
body: <p>I am looking to display an error message on the page when someone enters the incorrect username or password.  Right now it uses a popup box to display the message but I want it on the page itself.  How would I go about doing this? Below is my php</p>
  
  <pre><code>&lt;?php
      if(!defined("SESSION")){
         session_start();
         define("SESSION", true);
   }
   if(isset($_GET["log_out"])){
      unset($_SESSION["logged_in"]);
      header('refresh: 0; url=login.php'); 
      exit;
   }
  
   $login = true;
   require "protect.php";
  
   $logins[0]["user"] = "";
   $logins[0]["pass"] = "";
   $logins[0]["redirect"] = "test.php";
  
   $logins[1]["user"] = "";
   $logins[1]["pass"] = "";
   $logins[1]["redirect"] = "";
  
   $logins[2]["user"] = "";
   $logins[2]["pass"] = "";
   $logins[2]["redirect"] = "test.php";
  
   // No need to edit below, except the errors
  
   if(isset($_POST['submit'])){ //is the form submitted?
       if(empty($_POST['user']) || empty($_POST['pass'])){
       header("Location: login.php");
       exit;
    } //check for empty user name or password
    $is_logged = false; //this is part of the process to see if they have a correct password or not, set to false right here to say no right pass... (will change later)
    foreach($logins as $login){
    $user = $_POST;
       if(($user["user"] == $login["user"]) &amp;&amp; ($user["pass"] == $login["pass"])) {
     $is_logged = true;
     $_SESSION["logged_in"] = array($login["redirect"], true); //now, if they do have a correct password, set the session to true, and the variable.
    header("Location: ".$login["redirect"]);
    exit;
    }
   }
   if(!$is_logged){ echo '&lt;script type="text/javascript"&gt;alert("Inncorect username or password");window.history.go(-1);&lt;/script&gt;'; } //if none of the $logins arrays matched the input, give an error
   }
   ?&gt;
  </code></pre>