title: email validation in php
body: <p>I'm trying to validate my username as an email address, however PHP isn't letting me do this! what's wrong here? </p>
  
  <pre><code>//This checks if all the fields are filled or not
  if (!empty($_POST['username']) || 
  !empty($_POST['password']) ||
  !empty($_POST['repassword']) || 
  !empty($_POST['user_firstname']) ||
  !empty($_POST['user_lastname']) ){
  header('Location: register.php?msg=You didn\'t complete all of the required fields');
  }
  
  if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL) === false){
  $errors[] = 'The email address you entered is not valid';
  }
  </code></pre>
  
  <p>here is the form i used in register.php</p>
  
  <pre><code>&lt;form action="createuser.php" method="post" name="registration_form" id="registration_form"&gt;
  &lt;label&gt;Email&lt;/label&gt;
  &lt;input name="username" type="text" id="username" size="50" maxlength="50" /&gt;&lt;br /&gt;
  </code></pre>