Guest Posted June 29, 2006 Posted June 29, 2006 i'm trying to use the preg_match function to use a set of spammy words to filter from my contact form. (stop submission if the user is trying to use a spammy term)... but i cannot seem to work more than one term into it. code: if (preg_match(' /china/ ', rtrim($enquiry))){ $messageStack->add('contact_us', 'Not interested in your spam, thank you.'); $error = true; } i've tried: if (preg_match(' /china/ ', ' /poker/ ', rtrim($enquiry))){ $messageStack->add('contact_us', 'Not interested in your spam, thank you.'); $error = true; } but no luck. this seems to invalidate the entire code for some reason. what am i doing wrong here? i realize i could just use the captcha contribution.. but i'm trying as hard as possible not to aggravate my customers or potential customers with having to type useless codes just to send me an email.
Guest Posted June 29, 2006 Posted June 29, 2006 figured it out :) $patterns = array("china", "beijing", "travel"); $regex = '/(' .implode('|', $patterns) .')/i'; if (preg_match($regex, $enquiry)){ $messageStack->add('contact_us', 'Not interested in your spam, thank you.'); $error = true; }
Guest Posted June 29, 2006 Posted June 29, 2006 in contact_us.php i've added this (and other useful filters) into a contribution if you're interested: http://www.oscommerce.com/community/contributions,4358
Recommended Posts
Archived
This topic is now archived and is closed to further replies.