Preventing like user names: your suggestions please.

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

webaddict
Forum Commoner
Posts: 60
Joined: Wed Mar 14, 2007 6:55 am
Location: The Netherlands

Re: Preventing like user names: your suggestions please.

Post by webaddict »

JAB Creations wrote:In example "JAB Creations" and "jabcreations" are essentially the same thing though I want to prevent this to preserve the uniqueness of each user name.
Sorry in advance for not answering your question, but why would you want to do the above? If you want the username to be unique, just make sure it is unique. I can not imagine in which context it would be helpful to decline a certain username because an existing one looks like it.

"JAB Creations" and "jabcreations" are not essentially the same thing, they are very different. I can image a policy that states that only [a-z] is allowed would do the same? Forgive me my ignorance; I just don't see why you're creating a problem that doesn't exist?

Just a quick example to justify my twadling above: taking a person named "Simon Eduard Gent" (yes, that could happen in the Netherlands ;)) with username "SE Gent". Now take another person named "Simon Egent", with the username "S Egent". See how that would form a problem? If you want to allow capital letters and spaces, don't strip them later?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Preventing like user names: your suggestions please.

Post by onion2k »

I'd use MySQL's SOUNDEX() function. Eg

Code: Select all

SELECT `user_id` FROM `users` WHERE SOUNDEX(`username`) = SOUNDEX("jabcreations")
Similar sounding usernames will return the same value because they sound alike.. for example, "jabcreations" and "Jab creations" both return "J126352" so they'd match. "webaddict" and "webaddikt" both return "W1323" so they'd match too. It'll stop people posing as someone already on the site. But, and this could be a problem, it will fall over on 'hax0r' spellings ... "onion" and "0n10n" will not match (although minor changes are found ... "onion" and "on1on" do match).
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Preventing like user names: your suggestions please.

Post by Zoxive »

Most sites these days limit to what can be in the username. ex. [a-z0-9_-]
Basically once you limit the usernames with somes rules, then it becomes easier to see if that username already exists.

However there is some great advice in this thread for finding usernames that sound alike and/or are similar.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Preventing like user names: your suggestions please.

Post by VladSun »

JAB Creations wrote:However I only see trim() and it only removes starting and ending whitespace. Are there any other functions not listed here that would remove all white spaces? Google isn't being very helpful with this particular question. :|
Jab... http://dev.mysql.com/doc/refman/5.0/en/ ... on_replace ?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Preventing like user names: your suggestions please.

Post by JAB Creations »

I currently have a maximum number of 32 characters allowed for user names. If I had a million users that would be roughly 32 megabytes of user names worst case scenario, though what is the average length of a user name? I don't think having a second column of user names minus the letter casing and spaces to be used simply for preventing nearly identical user names would be too detrimental, especially since this is only done during registration. Additionally pretty much everything else is executed before the regex is thus reducing the overall likelihood of unnecessary queries. Plus with VladSun's awesome recommendation about using The Regex Coach I'm now able to test and reduce the number of steps (and thus server load) of my regex filters by using it's double highlighting feature in the steps tab. In example on a three letter string I was able to reduce the number of steps from 20 to 10 by adjusting my a regex string; I'm sure that would have a noticeably positive effect on server performance! Frankly if my work ever started getting so large as the server load from just registration was beginning to become detrimental I would hope that I would be able to afford a second cheaper server that I could assign to registration to a sub-domain on a separate server as from my current understanding large websites (such as Google and Microsoft) just can not be run on a single machine. Oh how I can't wait to be asking the questions here associated with that sort of setup! :twisted:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Preventing like user names: your suggestions please.

Post by VladSun »

JAB Creations wrote:... Plus with VladSun's awesome recommendation about using The Regex Coach ...
You should thank Kieran Huggins, I think. This link was in his signature as far as I remember.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Preventing like user names: your suggestions please.

Post by JAB Creations »

Where has he been of late? :| I checked his profile, he has something different linked? Maybe his tastes have changed?
Post Reply