phpQuestioner Posted August 17, 2007 Share Posted August 17, 2007 OK - So I keep getting this same spam email; using the same word and I have decided to try to create a script that will block email from being sent if my $comment variable contains a specific word. I think my script is kind of close, but it still is not not right just yet. I was wonder if some one could take a look at it and tell me how I could fix it to work the way I want it to. Does any one know what I need to correct in my script to make it work the way I want it to. <?php $comment = addslashes($_POST['comment']); $stupidspammer=array("Website","Email","Link"); while ($commment = $stupidspammer) { echo "We Are Not Interested"; exit; } // mail email stuff here ?> Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/ Share on other sites More sharing options...
Azu Posted August 17, 2007 Share Posted August 17, 2007 I don't think it's a good idea to block all emails that have one of those words in it. It would be better to just block emails that have the URL of the spam site in it (the spam emails are including a URL, right?) Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-326980 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 well it is not specifically those words - that is just an example the url varies, but in the intro of their spam pitch; they use specific words Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-326982 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 could someone tell me how I can correct my script to make it work? Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327010 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327046 Share on other sites More sharing options...
dbo Posted August 17, 2007 Share Posted August 17, 2007 you're while loop is doing assignment not comparison. try == for starters. Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327048 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 ok - simple mistake - but that did not help - form is still sending mail I need to check the entire $comment variable's string to make sure it does not contain specific words; this is what I am trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327053 Share on other sites More sharing options...
dbo Posted August 17, 2007 Share Posted August 17, 2007 look into preg_match Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327059 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 Ok - So I tried preg_match - but I still am not doing something right. <?php $stupidspammer=array("Website","Email","Link"); if (preg_match($stupidspammer, $comment) echo "We Are Not Interested"; exit; } ?> So where to from here? Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327068 Share on other sites More sharing options...
sasa Posted August 17, 2007 Share Posted August 17, 2007 try[code[<?php $stupidspammer=array("Website","Email","Link"); if (eregi('('.implode('|',$stupidspammer).')', $comment)){ echo "We Are Not Interested"; exit; } else { echo 'good'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327076 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 sasa - I tried the script you provided; but it still let email go through. Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327085 Share on other sites More sharing options...
phpQuestioner Posted August 17, 2007 Author Share Posted August 17, 2007 no I'm wrong - it did work - I just had a cookie set to prevent spammer from sending more then one email in a day ( a little something I had tried before; but did not fully block spammer) Thank You Sasa !!! Quote Link to comment https://forums.phpfreaks.com/topic/65487-solved-email-form-word-filters/#findComment-327091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.