This is a bit rough, there's probably a better way. But this works.
// Array of blocked words
$bad_words[0] = "badword1";
$bad_words[1] = "badword2";
$bad_words[2] = "badword3";
foreach($bad_words as $word) {
if(strpos(strtolower($email_message), $word) !== false) {
// Set flag to check when you exit the loop
$message_ok = false;
}
}
if(!$message_ok) {
// Some code to be executed if a vulgar word is found
}
Lsmjudoka
Junior Poster in Training
75 posts since Apr 2009
Reputation Points: 10
Solved Threads: 9
If the email is only going to you - what's the problem? Spam? If you're upset by profanity, I bet it's gonna upset the f*** out of you to type in those words which you wanna filter out in the first place.
IF you're worried about automated spam, put a captcha field in your form. Also, have a timeout feature that only allows one post per 15 minutes from a particular IP address. Coz I could send b0ll0ck5 to you, you BUGG3R, and you probably won't pick it up. (Sorry no offence!)
Having the filter won't hurt, but it won't stop all of the brown stuff slopping through the mailbox.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080