This is a version of the reCAPTCHA support hack for simpleContact Lite. See the version for simpleContact Pro for additional background information.
---------------------------------------------------------------------------------------------------------
You can view a live demo of this hack to see the end result of the process.
---------------------------------------------------------------------------------------------------------
The steps to implementing it are as follows:
First, you must visit http://recaptcha.net and sign up for a free account. You can choose your own username and password and enter the domain (or domains) that you want to use reCAPTCHA on. You will be provided with a private key and a public key. You will need both of these to implement this hack.
1) Download reCAPTCHA PHP library
Download the reCAPTCHA PHP library and upload it to your sc_admin/include/contact folder.
2) Modify contact form validation
Open sc_admin/include/contact/posted.php
Add the following code from line 2:
$publickey = "YOUR-PUBLIC-KEY-HERE";
$privatekey = "YOUR-PRIVATE-KEY-HERE";
Add the following code from line 186 (on one line):
$resp = recaptcha_check_answer($privatekey,$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
Add this code onto the next line:
if (!$resp->is_valid) { $err_recaptcha = "reCAPTCHA entered incorrectly"; }
3) Modify contact form
Open contact.php
Add this code after line 4:
require_once 'sc_admin/include/contact/recaptchalib.php';
Before the form submit button add these lines:
<?php
print recaptcha_get_html($publickey);
if (isset($err_recaptcha)) { printf("<p class=\"err\">%s</p>",$err_recaptcha); }
?>
4) CSS changes
Open screen.css
Find the line that says:
div.obj p {
Replace it with:
div.obj p, p.err {
If you visit your contact form in your web browser you should now have a reCAPTCHA with working validation.