I am trying to make a password validator and have run into a problem. It seems my code won't read special character. below is my code:
<?php
$Passwords = array(
'Pas$word1',
'Pas$word2',
'Pas$word3',
'Pas$word4',
'pas$word1',
'PAS$WORD1',
'Password1',
'Pas$word',
'Pas$word 1',
'Pas$word1234567890',
'P$wd1');
function validatePassword($Password)
{
if (preg_match("[^!-/0-9A-Za-z]", $Password)==1)
{
return TRUE;
}
else
{
return FALSE;
}
}
foreach ($Passwords as $Password)
{
if (validatePassword($Password) == false)
{
echo "<p>The password <em>$Password</em> does not appear to be valid.</p>";
}
}
echo "<p>Processing has completed.</p>";
?>
fixed my array so it has single quotes, everything is now displayed. Current problem is that everything is displayed. What is wrong in my validatePassword function?
Any help would be appreciated.