Hi,
I think the captcha is working. But it's not working completely.
I tried the following code, and there are 3 different cases.
1. when I fill in the correct captcha it goes to a page and echo's out the alert "OK".
2. when I fill in an incorrect captcha it goes to a page and echo's out the alert "Error".
3. when I don't fill in the captcha, it reloads the page and sends the email. It shouldn't send an email in this case.
This made me realize that I need to have some validation for the recaptcha if it's empty. But it's static text. So how do I add validation here?
require_once('administrator/components/com_breezingforms/libraries/recaptcha/recaptchalib.php');
$privatekey = "XXxxxXXXXXxxxxXxxXx";
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) {
echo '<script type="text/javascript">
//location.go(-1);
alert("Error");
</script>';
exit;
}
else
{
echo '<script type="text/javascript">
alert("OK");
</script>';
exit;
}
}
EDIT: Turns out that when you fill in a wrong captcha it reloads the page and sends the email. This also shouldn't happen. So in all cases the email is beign sent.