photo

Lee Forbes

shared this idea
6 years ago

Statistics

0
Comments
359
Views

Relates to

Share

Tags

1
votes

How about using some simple regex to thwart spam?

I am using the below code in a contactform addon and would love to see it used within OR's lead forms. It runs the form POST data through a check and throws an error if the phone number is spoofed or if there is a URL within the message body. It has stopped the spam bots 100% without using captcha for my sites. if(trim($_POST['name']) == '') {

$error[] = 'email_no_name';

}

if(trim($_POST['email']) == '') {

$error[] = 'email_no_email_address';

} elseif(addon_validate_email($_POST['email']) !== TRUE) {

$error[] = 'email_invalid_email_address';

}

if(trim($_POST['subject']) == '') {

$error[] = 'email_no_subject';

}

if(!preg_match('/^([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}$/', $_POST["phone"])){

$error[] = 'phone_num_spoof';

}

if(trim($_POST['message']) == '') {

$error[] = 'email_no_message';

}

if(preg_match('/(.*)http(.*)|\

Under Consideration
+1 I like this idea

Leave Comment

photo

Attach files...

The file must be a jpg, gif, png, bmp, ico, pdf, doc, rtf, txt, zip or rar no more than 20M