Preventing Bad Usernames in Registration Form

I have a registration form where I need to prevent people entering bad usernames. For example, people when they enter their username as virus, then the form should not be accepted. How can I prevent bad usernames in my Registration forms. Is there any function to do the same? Please help. Thanks in advance.

you're going to spend a lot of time reinventing the wheel here. perhaps use an open source registration script. it will save you hours of work, and thousands of headaches.

Yes, I agree, I googled on this, there are no ways to stop the spammers to register swear words. Anyway, thanks for all your support.

diafol

7 Years Ago

there are no ways to stop the spammers to register swear words

I thought I just gave you an example?

If you check out phpBB3 - they have a banned words table and these are checked against strings. You need to ensure that you check lowercase strings with lowercase banned words. You can do this with strtolower or mb_strtolower. The second is safer when using extended characters (accented / foreign characters).

If they are real human spammers, they will always find a way to do it :(

best regards

diafol

7 Years Ago

Using these alternatives to me seem OK as the word isn't clear. But if you want to be as clean as possible...

f*ck or f_ck or whatever is an obvious one - you can still filter this out with something like "/((f[^aeiowy])ck(er|ing)*)/i".

The difficulty comes when users try to create - I'll use the work funk for an eexample:

f-u-n-k, f_u-n_k etc. You can only do so much as mentioned earlier, but general matches should wipe out 90%(?) of the dross. Keep an eye on users and change their names or ban them when you come across one that goes against the site rules.