title: PHP form validation using preg_match for password checks
body: <p>This is a general question on password form validation and using a combination of uppercase, lowercase, numbers and characters used.</p>
  
  <p>Research has showed that preg_match is required to validate the password (or whatever variable you use): (preg_match("/^.<em>(?=.{8,})(?=.</em>[0-9])(?=.<em>[a-z])(?=.</em>[A-Z]).*$/")</p>
  
  <p>Though how would how would i integrate this into the if statement below? I've tried combining them using &amp;&amp; though this seems to ignore the preg_match part. if(($pass == $pass2) &amp;&amp; (preg_match("/^.<em>(?=.{8,})(?=.</em>[0-9])(?=.<em>[a-z])(?=.</em>[A-Z]).*$/"))</p>
  
  <p>Any advice would be appreciated.</p>
  
  <pre><code>&lt;?php
  
  require "dbconn.php";
  
  $username = ($_GET['username']);
  $email = ($_GET['email']);
  $pass = ($_GET['pwd1']);
  $pass2 = ($_GET['pwd2']);
  $USN = ($_GET['schoolnumber']);
  
  $matching = 0;
  
  if($pass == $pass2)
  {
  echo "&lt;script type='text/javascript'&gt; window.alert('Your details have been successfully    registered, please proceed to login with your new credentials!')&lt;/script&gt;";
  echo '&lt;script&gt;javascript:window.close();&lt;/script&gt;';
  
  
  $query = "INSERT INTO customer VALUES     ('".$username."','".$email."','".$pass."','face1.jpg','".$USN."','N')";
  
  $results = mysql_query($query) or die (mysql_error());
  
  $results1 = mysql_query($query1) or die (mysql_error());
  }
  else{
  
  header('Location:register.php?matching=1');
  
  }
  ?&gt;
  </code></pre>