October 25, 201213 yr Hi, I'm getting spammed quite a bit at the moment, and instead of adding a captcha which I don't really like using, I thought I might use something that blocks certain keywords. I got some free PHP script and have modified it a bit, but don't know how to add more than one keyword to the script. If you click on the link and type in bad, then it will work, but how do I add further keywords to this script? http://www.professionalwebdesigndirectory.com/bad-word-form.php Not to hot on PHP and would be really gratefully for any help!
October 25, 201213 yr Pretty difficult without seeing the code. I presume its an array of bad words or something like that?
October 26, 201213 yr Author Sorry, <?php ################################################### ####### ##### ################################################### # Declare what word you dont want to allow $forbiden_word="bad"; # if $forbiden_word matches the submited word, clean it if($_POST['word']==$forbiden_word) { $goodword= str_replace($forbiden_word,"",$_POST['word']); $message='Sorry: <span class="style2"><strong>'.$forbiden_word.'</strong></span> is not allowed!<span class="style2"><strong>'.$_POST[''].'</strong></span><span class="style3"><strong>'.$goodword.'</strong></span>'; } else { $message='<span class="style3"><strong></strong></span>'; } # If the form has not been sumbited, use the default message if(!$_POST['word']) { $message=''; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled</title> <style type="text/css"> <!-- .style2 { color: #FF0000; font-weight: bold; } .style3 { color: #009900; font-weight: bold; } --> </style> </head> <body> <div align="center"> <p> </p> <p align="left"> </p> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> <table width="500" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#CCCCCC"> <tr align="center" bgcolor="#FFFFFF"> <td colspan="2" nowrap><?php echo $message; ?></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">Location</td> <td><input type="textfield" name="word"></td> </tr> <tr bgcolor="#FFFFFF"> <td> </td> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <p align="left"> </p> </div> </body> </html>
October 26, 201213 yr $badwords = array("adult", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur" , "seminar","SEO","content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript","x-x","<a","http","[","href"); foreach ($badwords as $word) if (strpos($_POST['word'], $word) !== false) $points += 1; if ($points>3){ /// Probably a spammer so do something /// echo a message or redirect to another page /// anything except let the rest of the script send the email } Are you sure you would not like a complete ready made email script? Edited October 26, 201213 yr by Sogo7
Create an account or sign in to comment