Hi everyone,
I've created a web form which among many other things is submitted via
ajax so that the page is not refreshed. see here:
http://www.blueleafstudio.net/?page_id=49
However i'm having some huge problems integrating recaptcha with what
i have. I have the following function in my Ajax file:
function validateCaptcha()
{
challengeField = $
("input#recaptcha_challenge_field").val();
responseField = $("input#recaptcha_response_field").val();
//alert(challengeField);
//alert(responseField);
//return false;
var html = $.ajax({
type: "POST",
url: "
http://www.blueleafstudio.net/wp-content/themes/
blueleaf1/ajax.recaptcha.php",
data: "recaptcha_challenge_field=" + challengeField +
"&recaptcha_response_field=" + responseField,
async: false
}).responseText;
if (html.replace(/^\s+|\s+$/, '') == "success")
{
$("#captchaStatus").html("Your captch is correct!!");
// Uncomment the following line in your application
return true;
}
else
{
$("#captchaStatus").html("Your captcha is incorrect.
Please try again");
Recaptcha.reload();
return false;
}
}
then it should be validated by ajax.recaptcha.php (with the keys in!):
<?php
require_once('recaptchalib.php');
$publickey = "MY PUBLIC KEY"; // you got this from the signup page
$privatekey = "MY PRIVATE KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
session_start();
echo 'success';
$_SESSION['captcha'] = 1;
}
else
{
die ("The reCAPTCHA wasn't entered correctly. Go back and try it
again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
?>
However when i insert:
return validateCaptcha();
it always returns false?
Can any one help? i'm out of my depth with this!