Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP Contact Form SPAM! Re: PHP Contact Form SPAM!

#67077
gno
Member

Preeminent, theres a much simpler solution to your problem than implementing a captcha check. Recaptcha is nice, and easily styleable if you know your way around with php. But Recaptcha, or anything like it would be overkill.

Most likely you are a victim of spam bots, the same kind of bots that we protect our blogs against with comment moderation, plugins and what not. Those spam bots are easily tricked;

All it takes is to add a input field (input type=”text-ish) and hide it with css (display: none;). That field will be empty, whenever someone visits your page in a browser and submits a message. Because they cant fill it out, due to it being hidden. But said bots, wont view your site in a browser – they’ll look at the markup, searching for forms. They fill out anything they find and submits it.

So if you just make sure that the check-input field is empty before you send the email to yourself, you can avoid the spam.

The code needed to implement this simple solution:
The HTML:

The CSS:

input.check { display: none; }

The PHP: (just wrap your current script in this if statement)


if ($_POST == '') {
// YOUR SEND-EMAIL-SCRIPT GOES HERE
}
?>

I hope that it will be useful for you!