View Full Version : simple filter but ..?

09-07-2005, 12:31 PM

i need a quick basic help..it about filtering message for the words..spma words to be exact.. i have email form builtin php on my swebsite now robots come and fill the forms with word "poker" in the From or SUbject or MEssage part or email and send as junk to my hidden email account. i want this things to be filtered out using a EXTERNAL FILTERWORDS.TXT file.

so all the email message that it $MESG is checked of it contains any word listen in FILTERWORDS.TXT and if it does the visitor is redireted to www.google.com ( example) if it doesnt then the mail is sent and thankyou.php is continued..

any one can help me with this filter words script with external file containg banned words ?


09-07-2005, 01:14 PM
header("Location: http://www.google.com");

function filter($message){
$lines = file("FILTERWORDS.txt");
foreach($lines as $line){
if(strpos($message, rtrim($line))){
return false;

return true;

09-07-2005, 01:46 PM

it didnt work gave "PARSE error" on running..

dunno y.. some1?

09-07-2005, 01:47 PM
i am trying to implement the check for bad words on this page



09-07-2005, 01:55 PM
post edited with corrections - I missed the brackets round the if statements (been working in asp all day)

09-07-2005, 04:40 PM
I want to add a suggestion here as well.
You're problem is that bots are submitting your forms correct? You may want to look into making use of php's GD Library extensions to create a random code. Users can view and type this in, however bots cannot. This could then be used to direct them to a new page, something like 'Not all fields completed'. This is by no means the easiest route to do this with, but I'd recommend it if available for registrations and whatnots. Considering as well that I only allow emails sent from registered users, I've never had a problem with a bot, as they can never become registered users.
Just a suggestion though...