Jump to content

Username & Password comparison!


cashflowtips

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/68948-username-password-comparison/
Share on other sites

<?php

$username="admin";

$password="admin123";

$cheek1=substr($username,0,3);

$cheek2=substr($password,0,3);

if($cheek1==$cheek2){

echo "Sorry the username and password have the same first three letters";

}else{

echo "Username and password are valid as the first three letters dont match";

}

?>

<?php

$username="admin";

$password="admin123";

$cheek1=substr($username,0,3);

$cheek2=substr($password,0,3);

if($cheek1==$cheek2){

echo "Sorry the username and password have the same first three letters";

}else{

echo "Username and password are valid as the first three letters dont match";

}

?>

 

thank you for you reply... really appreciate it... i have another question. can it trace something like this :-

 

user name : 12admin99

password : !(admin)!

 

will it return true or false?

the above is nice.  here's an alternative which would also catch a password of "theadmin" or "1admin"

 

<?php

$username="admin";

$password="admin123";

$cheek=substr($admin,0,3);

if(strstr($password,$cheek)
{
echo "Sorry the username and password have the same first three letters";
}else{

echo "Username and password are valid as the first three letters dont match";

}

?>

You can make use of this functions to find the similarities between the username and password in percentiles..

If the similarity rate is high , then you can fail this attempt ..else success.

 

similar_text

http://www.php.net/manual/en/function.similar-text.php

 

Levenshtein

http://www.php.net/manual/en/function.levenshtein.php

 

You can find similar_text more flexible.

::)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.