This 4 step is to install Re-Captcha into your php-fusion contact form,
extract recaptchalib.php in the directory where you your forms live.
- First, add this code to the head of your files:
require_once('recaptchalib.php');
$publickey = "..."; #take it from http://recaptcha.net/api/getkey?app=php
$privatekey = "..."; #take it from http://recaptcha.net/api/getkey?app=php
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
- Add this code to validate the CAPTCHA by changing the "sendmessage" condition. Otherwise, the CAPTCHA will appear, but the answers won't be checked. The validation code looks like:
- Then add the code to display re-captcha, i prefer to put it before submit html process:
echo recaptcha_get_html($publickey, $error);
if (!$error) {
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid)
{
require_once INCLUDES."sendmail_include.php";
sendemail($settings['siteusername'],$settings['siteemail'],
\$mailname,$email,$subject,$message);
opentable($locale['400']);
echo "\n".$locale['440']."\n".$locale['441']."\n";
closetable();
}
else
{
opentable($locale['400']);
echo "\n".$locale['900']."\n";
closetable();
}
$locale['900'] = "Wrong re-captcha entry!"
get full script here, modify it as you want :)
cheers.
what about adding this to the news comment section? (version 7)
ReplyDelete@Anonymous: sorry. not yet using ver.7 maybe later, for a while, just search google for it :)
ReplyDelete