title: Add validation for empty inputs to current PHP Login form
body: <p>I currently have a form that checks if the username and password exist and logs you and redirects you to the homepage. However if you leave the email and password section blank, you also are able to log into the site. I'm looking to add some sort of validation to avoid someone from just using empty input variables.</p>
  
  <p>This is what I have...</p>
  
  <pre><code>&lt;?php
  session_start();
  include_once 'config.php';
  $email ="";
  $userpassword ="";
  $errors = 0;
  
  $emailError ="";
  $passwordError ="";
  
  if(isset($_SESSION['user'])!="")
  {
   header("Location: home.php");
  }
  if(isset($_POST['loginBtn']))
  {
  if(!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL))
  {
  $emailError = "Email is not valid";
  $errors = 1;
   }
  
  if(!empty($_POST["password"])) {
  
  $passwordError = "Please enter a Password";
  $errors = 1;
  }
  
  $email = mysql_real_escape_string($_POST['email']);
  $userpassword = mysql_real_escape_string($_POST['password']);
  $result=mysql_query("SELECT * FROM users WHERE emailAddress='$email'");
  $row=mysql_fetch_array($result);
  
  if($row['password']==md5($userpassword))
  {
   $_SESSION['user'] = $row['user_id'];
  
   header("Location: home.php");
   }
   else
   {
    ?&gt;
      &lt;script&gt;alert('First time visitors, please create an account to play');      &lt;/script&gt;
      &lt;?php
    }
  
    }
  
    ?&gt;
  </code></pre>