Reputation: 61
I run a NFL pick em site and lately have been getting a lot of spam. My sign up page just throws the info from the sign up form in to a database, but I can't figure out how to get reCaptcha working.
I have the captcha showing up and everything, but currently it does not matter if you fill out the captcha or not... I've even typed random letters in it and it still went through. So basically you can sign up for my site and ignore the captcha all together.
Here is my code:
(I couldn't get the code to format properly on here...)
Upvotes: 0
Views: 97
Reputation: 50600
If you fail validation you are just filling an errors array and continuing with your script.
// begin: reCAPTCHA - VALIDATE
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$errors[] = 'Please enter a valid captcha';
}
// end: reCAPTCHA - VALIDATE
You need to wrap everything after this point in an else
block, otherwise you just fill your $errors
array and happily proceed with the rest of your page. You aren't even using your $errors
array later.
Upvotes: 1