0

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.

5
Contributors
12
Replies
14
Views
5 Years
Discussion Span
Last Post by diafol
0

If i have to include a file as badwords.txt, then what code to write?

0

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.

0

Have a database table (or array) with all the banned words - then use preg_match($pattern,$username) or similar, where $pattern could be,e.g.

"/(virus|git|fool)/i"

If you have an array of banned words:

$banned = array('virus','god','blast'...);
$pattern = "/(" . implode("|",$banned) . ")/i";

think it'll work - not tested.

0

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.

0

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).

0

Yep it's almost impossible :( ie -> v*rus or vir_us will not be detected on the solutions you have here (although they are correct)

I really all depends on what kind of spam we are talking about.. if it is a boot
I strongly recommend wcaptha
http://wcaptcha.wozia.pt/sample.php

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

best regards

0

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.

Edited by diafol: n/a

0

ardav :)
I agree with you.. but I think that that filter will also stop words like funcky :D

I think the best solution to this problem.. is your solution, but it's not bullet prove :)
That is why I recommend looking at it from a different angle ;)

Edited by migcosta: n/a

0

Hi Ardav,

Can you help me with the exact code, let me try once more with your help...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.