title: How to show error messages in HTML page in PHP?
body: <p>I have following login form (login.php) in which I am asking for username and password.</p>
  
  <pre><code>&lt;form action="processlogin.php" method="post"&gt;            
    &lt;input type="text" name="username"&gt;
    &lt;input type="password" name="password"&gt;
    &lt;input type="submit" value="Login"&gt;                                
  &lt;/form&gt;
  </code></pre>
  
  <p>Following is the code snippet from my processlogin.php file</p>
  
  <pre><code>if(!$_POST["username"] || !$_POST["password"])
  {
      $msg = "You left one or more of the required fields.";
      echo $msg;
      //header("Location:http://localhost/login.php");
  }
  </code></pre>
  
  <p>This code checks whether all the mandatory fields are filled on not. If not, it shows the error message.</p>
  
  <p>Till now everything is fine.</p>
  
  <p>My problem is that, error message is shown in plain white page. I want to show it above the login form in login.php file. How should I change my code to get
  my functionality.</p>