In: Computer Science
Create a web form that will accept a string as a password and determine the strength of that password. The strength of a password is determined by the characters making up the password. These characters are divided into three categories:
USING PHP
The uppercase characters, which are
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z The lowercase
characters, which are
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
The special characters which are ~!@#$%^&*()_?+><
The strength of the password can be:
INVALID : if the string is less than 8 characters long or has invalid characters
POOR: if the string contains only one set of the above characters in it
MEDIUM: if the string contains only two sets of the above characters in it
GOOD: if the string contains all three sets of the above characters.
T
Strength Message should display “INVALID”, “POOR”,”MEDIUM” or “GOOD”.
For “INVALID”, “POOR” or ”MEDIUM” strengths give the reason(s) why. The Reason
is less than 8 characters”,
does not contain uppercase characters”
does not contain lowercase characters”
does not contain special characters”
does not contain uppercase or lowercase characters” does not
contain uppercase or special characters” does not contain lowercase
or special characters” contains uppercase, lowercase and special
characters” contains invalid characters”
“Password
“Password
“Password
“Password
“Password
“Password
“Password
Message can be:
“Password
“Password
HTML page :
<html>
<body>
<form action="validate_password.php" method="post">
Password: <input type="password" name="password">
<input type="submit">
</form>
</body>
</html>
PHP code (validate_password.php):
<?php
$password = $_POST["password"]
$uppercase = preg_match('@[A-Z]@', $password);
$lowercase = preg_match('@[a-z]@', $password);
$special_chars = preg_match('/[^a-zA-Zd]/', $password);
$length = strlen($password);
if ($length < 8)
{
echo "INVALID. Reason is less than 8
characters";
}
elseif ($uppercase && $lowercase &&
$special_chars)
{
echo "GOOD";
}
elseif ($uppercase && $lowercase)
{
echo "MEDIUM. Reason is does not contain special
characters";
}
elseif ($uppercase && $special_chars)
{
echo "MEDIUM. Reason is does not contain
lowercase characters";
}
elseif ($lowercase && $special_chars)
{
echo "MEDIUM. Reason is does not contain
uppercase characters";
}
elseif (!$uppercase && !$special_chars)
{
echo "POOR. Reason is does not contain uppercase
and special characters";
}
elseif (!$uppercase && !$lowercase)
{
echo "POOR. Reason is does not contain
uppercase and lowercase characters";
}
elseif (!$lowercase && !$special_chars)
{
echo "POOR. Reason is does not
contain lowercase and special characters";
}
else{
echo "GOOD";
}
?>
PLEASE THUMBS UP!!!!!