I'm loading Recaptcha using this:
<script src="//www.google.com/recaptcha/api/challenge?k=key"></script>
and using AJax and PHP to validate the response:
$ch=curl_init('http://www.google.com/recaptcha/api/verify');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'privatekey'=>'key',
'remoteip'=>$_SERVER['REMOTE_ADDR'],
'challenge'=>$_POST['recaptcha_challenge_field'],
'response'=>$_POST['recaptcha_response_field']
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response=@curl_exec($ch);
if(substr($response,0,4)!='true')
die('The verification code is incorrect.');
For some reason, if I enter the Captcha incorrectly, then re-enter it correctly, the verification always returns "false". How do I allow the user the resubmit the Recaptcha response (without reloading the image) if they entered it incorrectly the first time?