So im making my own registration form and i have it so they enter there username and password that is desired. But ive noticed with the bigger sites it won't let you have a username with a password that are similar to each other, does anybody know of a coding that would make it so user couldn't have similar enteries like that? thanks , brandon
I don't know right off. I've never written anything to do that. After a few seconds thought though, I could think of one possible way to do it. You could always run through a loop and take each possible series of 4 consecutive characters in the username and compare it to the psasword. For example, if the username is ajscottsr, you could compare the password to see if it contains ajsc, jsco, scot, cott, otts, ttsr and reject it if you hit a match. I'm sure there are plenty of other ways, perhaps some better. That's just one possible suggestion that I could think of after giving it 30 seconds thought.
It is easy enough to check whether their password is the same as their username but picking up small differences could be hard. It depends how strict you want the test to be. A good place to start might be looking for a fragment (substring) of one value in the other. A substring of 3 characters or more you might want to avoid while 2 character substrings are probably acceptable. [edit]Looks like ajscottsr beat me to it. I guess thats what happens when you get distracted while posting.[/edit]
Luckily I'm a walking php function reference lookup and remembered a few functions which might help you. php.net/levenshtein php.net/similar-text
I need one of those (walking php reference function lookup) Very cool functions indeed - rep to ya... As I said in my response, that was 30 seconds of thinking to come up with that solution. When/if the time comes to actually use something like that, no doubt a search to php.net and/or other respectable sources would have occurred first .