Contact Form Spam Issues

I have a relatively simple contact form on a wordpress website. I have been getting floods of spam recently. I’m concerned about implementing a captcha for conversion reasons. All of the spam entries have a website url (either “http://” or “www.”) at least once in the contact form submittal.

Is there a way to prevent the form from executing (hence, I won’t receive an email) if “http://” or “www.” is submitted on the contact form?

Read More

Can anyone tell me how to implement this code?

Related posts

Leave a Reply

2 comments

  1. Sure. You will need to locate the code or method that handles or processes the incoming form data. Next all you would need to do is interrupt the process.

    Lets say the current processing looks like this.

    function handleContactFormData() {
        if (isset($_POST['from']) && isset($_POST['message']) {
            // put 'from' or 'message' into a DB or email message.
        }
    }
    

    Get in the way of the handling if ‘http://’ or ‘www.’ are found in the message.

    function handleContactFormData() {
        if (isset($_POST['from']) && isset($_POST['message']) {
            if (stripos($_POST['message'], 'http://') !== false || stripos($_POST['message'], 'www.') !== false)
                return;
            }
            // put 'from' or 'message' into a DB or email message.
        }
    }
    

    Of course this is highly dependent on how the data is being processed, and what you want the result to be to a user that posts such data to be. But then again, you didn’t post any code at all.