I am trying to get a different error for each type: missing uppercase, missing lower case, missing number, or space. The length seems to be the only thing working. I am guessing because it is at the start of the code. I have tried different variations and can't seem to get it working.
<?php
$Passwords = array(
"F!ve5",
"This !s12",
"w!zard12",
"W!ZARD12",
"W!zardJK",
"Wizard12",
"!Qazxsw2",
"@Wsxzaq1",
"@Wsxcde3",
"#Edcxsw2");
foreach ($Passwords as $StongPass) {
echo "<p>The Password “" . $StongPass .
"” </p>";
if (strlen($StongPass)<8)
echo "Password is to short!";
elseif (strlen($StongPass)>16)
echo "Password is to long!";
elseif (preg_match('/P[A-Z]/', $StongPass))
echo "Password does not contain an upper case letter!";
elseif (preg_match('/P[a-z]/', $StongPass))
echo "Password does not contain a lower case letter!";
elseif (preg_match('/P[!@#$%^&*()\-_=+{};:,<.>]/', $StongPass))
echo "Password does not contain a special letter!";
elseif (preg_match('/P[0-9]/', $StongPass))
echo "Password does not contain a number!";
elseif (preg_match('/P[""]/', $StongPass))
echo "Password cannot contain any spaces!";
else
echo "Password is strong!";
}
?>
The results look like this "The Password “F!ve5” Password is to short! The Password “This !s12” Password is strong! The Password “w!zard12” Password is strong! The Password “W!ZARD12” Password is strong!"