i having a problem on how to check the user name and password during registration session... the input like this :- user name : admin password : admin123 /* False */ if something like this happen, the system should output error message because the password have partial words same as the user name. if can, i would like to limit it to allow only 3 consecutive letter to be same. example :- user name : admin password : admi123 /* False */ user name : admin password : adm789 /* True (allowed) */ can anybody help me here?
This doesn't exactly do what you want, but I guess it's close. function is_secure_pass($username, $password, &$percent = 0) { $passparts = preg_split('/\d/', $password, -1, PREG_SPLIT_DELIM_CAPTURE); foreach (array_filter($passparts) AS $part) { similar_text($part, $password, $p); if ($p > 70) { $percent = $p; return false; } } return true; } PHP: Usage example: $name = 'admin'; $pass = 'adm123'; if (is_secure_pass($name, $pass)) { echo 'Good password'; } else { echo 'Bad password'; } PHP: