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.
sammry
-3
Light Poster
Recommended Answers
Jump to Posthere you can use strpos.
if ( strpos($name, 'virus') !== false ) { echo 'virus not allowed try again'; }
I think an issue is if you were to use the name database and you filtered out the word data then it would still return false.
…
Jump to PostHave 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 - …
Jump to Postthere 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 …
All 12 Replies
reco21
4
Light Poster
sammry
-3
Light Poster
super9876
0
Newbie Poster
diafol
sammry
-3
Light Poster
diafol
migcosta
13
Junior Poster
diafol
migcosta
13
Junior Poster
diafol
sammry
-3
Light Poster
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.