Jump to content

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.

::)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.