Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PHP PASSWORD VALIDATE
- // Given password
- $password = 'user-input-pass';
- // Validate password strength
- $uppercase = preg_match('@[A-Z]@', $password);
- $lowercase = preg_match('@[a-z]@', $password);
- $number = preg_match('@[0-9]@', $password);
- $specialChars = preg_match('@[^\w]@', $password);
- if(!$uppercase || !$lowercase || !$number || !$specialChars || strlen($password) < 8) {
- echo 'Password should be at least 8 characters in length and should include at least one upper case letter, one number, and one special character.';
- }else{
- echo 'Strong password.';
- }
- # SOURCE https://www.codexworld.com/how-to/validate-password-strength-in-php/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement