Forums

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

Home Forums CSS Nice Simple Contact Form Re: Nice Simple Contact Form

#54296

I use reCaptcha for spam prevention. Simply sign up for an API key at http://recaptcha.net/ and download the reCaptcha PHP library from http://recaptcha.net/plugins/php/

To add the reCaptcha to the contact form you simply add the following code (must be a .php file):

Code:

Then to verify the captcha you add the following before the email is processed:

Code:
require_once(‘recaptchalib.php’);
$privatekey = “…”; // you got this from the signup page as well
$resp = recaptcha_check_answer ($privatekey,
$_SERVER[“REMOTE_ADDR”],
$_POST[“recaptcha_challenge_field”],
$_POST[“recaptcha_response_field”]);

if (!$resp->is_valid) {
die (“The reCAPTCHA wasn’t entered correctly. Go back and try it again.” .
“(reCAPTCHA said: ” . $resp->error . “)”);
}