Forum Moderators: coopster
if ($msg=="insert bad words") {
$error_msg[]='<strong>Go Away!</strong>';
}
do I separte my target keywords to block with commas or quotes? I've tried everything.
what you need is a clear head :) and review both links and each and every links within both links
Did I already confuse you?
First set [webmasterworld.com]
Second set [webmasterworld.com]
Another thread that might be a useful read... Frustrated with Spambots Coming In through Webmail Forms [webmasterworld.com]
Anyway, back to your original query of checking for the existence of any one of a list of words within a block of text. I'm not sure that this can be done within a simple IF statement unless a strpos()-like function exists that can take an array of strings/words to match (which I don't think it can)?
One way to do this is to store your list of bad words in an array, then step through this array searching for each word in your $msg. As soon as you find a $bad_word then fail...
$msg = 'This is my message containing a nasty word.';
$bad_words = array('bad','nasty','awful','rude','words');
$found_bad_word = false;
foreach ($bad_words as $word) {
if (strpos($msg,$word) !== false) {
$found_bad_word = true;
break;
}
}
if ($found_bad_word) {
echo '<p>Found a bad word: "'.$word.'"</p>';
} else {
echo '<p>No bad words found :)</p>';
}
As mentioned, I wouldn't use this bad words list to block a user (unless perhaps they persistently offend), but to perhaps warn that they have entered unsavoury content that should be corrected.
penders and I supplied a few links
you should invest time to implement such a system
one of the bots expert on board is alex, review, learn from the posts and seek help when needed.