Answer the question
In order to leave comments, you need to log in
Error in reCAPTCHA documentation?
The reCAPTCHA documentation on the Displaying reCAPTCHA Without Plugins
page contains the captcha embed code:
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=your_public_key">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key"
height="300" width="500" frameborder="0"></iframe>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
Answer the question
In order to leave comments, you need to log in
Where do you see the error or problem here?
Both values of these fields are needed when passing for validation.
Here we have, for example:
Client side (js):
recaptcha_c = $('#recaptcha_challenge_field').val();
recaptcha_r = $('#recaptcha_response_field').val();
public static function check()
{
if ( Ts_App::getConfig('recaptcha_enabled') ) {
$recaptchaC = Request::getVar('recaptcha_c');
$recaptchaR = Request::getVar('recaptcha_r');
if ( empty ($recaptchaC) || empty ($recaptchaR) ) {
return false;
} else {
$privkey = Ts_App::getConfig('recaptcha_priv_key');
$remoteip = Request::getIp();
if( $curl = curl_init() ) {
curl_setopt($curl, CURLOPT_URL, 'http://www.google.com/recaptcha/api/verify');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "privatekey={$privkey}&remoteip={$remoteip}&challenge={$recaptchaC}&response={$recaptchaR}");
$out = curl_exec($curl);
if ( !$out ) {
return false;
} else {
$responses = explode("\n", $out);
if ( $responses[0] != 'true' ) {
return false;
}
}
curl_close($curl);
}
return true;
}
} else {
return true;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question