title: How to check if any fields in a form are empty in php
body: <p>whenever I submit something in my form i want to check if any of the fields are empty.  So far what I have is not working</p>
  
  <pre><code>$firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $username = $_POST['username'];
  $password = $_POST['password'];
  $passwordconf = $_POST['passwordconf'];
  $email = $_POST['email'];
  $securityq = $_POST['securityq'];
  $qanswer = $_POST['qanswer'];
  
  if(empty($firstname) || empty($lastname) || empty($username) || empty($password) || empty($passwordconf) || empty($email) || empty($securityq) || empty($qanswer))
  {
      echo "You did not fill out the required fields.";
  }
  </code></pre>
  
  <p>and the form</p>
  
  <pre><code>&lt;form name="registrationform" action="register.php"&gt;
      First Name:&lt;input type="text" name="firstname"&gt;
      Last Name:&lt;input type="text" name="lastname"&gt;
      Email:&lt;input type="text" name="email"&gt;
      Username:&lt;input type="text" name="username"&gt;
      Password:&lt;input type="password" name="password"&gt;
      Confirm Password:&lt;input type="password" name="passwordconf"&gt;
      Security Question:&lt;input type="text" name="securityq"&gt;
      Answer:&lt;input type="text" name="qanswer"&gt;
      &lt;input type="submit" name="submit" value="Register"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and heres the registation page if it helps <a href="http://www.myjournal.tk/register.html" rel="noreferrer">http://www.myjournal.tk/register.html</a></p>