So I have a contact page on my site with a simple form with the following fields: Name Email Comments Just for users to submit errors on the site, etc. Lately I have been getting tons of Viagra, Vicodin, replica watch kind of stuff in my mailbox from the form. I wanted to make a list of banned words in an array that I could easily add to at any time and then have the code iterate through the array evaluating the "Name" input to see if any of the POSTed strings had any of the banned words in them. I also wanted to set it up so I could I easily use it in an already existing IF statement by adding an ELSEIF like the following: elseif (banned word exists) { (this would be blank or have a message saying it was rejected) } Can anyone please help me, ive been messing around with different techniques for hours and the form info is still running right through.
<? $banned = array ( "penis-pump", "viagra", "some other disgusting product only to be used by the weak and desperate" ); if($_POST) { foreach($_POST as $key => $value) { foreach($banned as $x) { if(preg_match("/$x/si", $value)) { die("error message here"); } } } } ?> PHP: EDIT : I made a mistake, copy it now
Use Captcha Image Verification (It worked for me): http://www.free-php-scripts.net/P/Contact_Form Peace,