Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

extra layer of protection on contact_us.php


Guest

Recommended Posts

Posted

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.

Posted

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;
}

Posted

where (and in which file) do you place that ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...