php – Google reCaptcha说:invalid-request-cookie
发布时间:2020-12-13 16:16:10 所属栏目:PHP教程 来源:网络整理
导读:这是我第一次在我的网站上使用recaptcha. 我正在使用PHP API验证recaptcha,它一直说无效请求cookie 我在不同的论坛上发现www.example.com与example.com不同,所以我在没有www的情况下再次注册我的网站,但它仍然无法正常工作.. 当我验证recaptcha_response_fie
这是我第一次在我的网站上使用recaptcha.
我正在使用PHP API验证recaptcha,它一直说无效请求cookie 我在不同的论坛上发现www.example.com与example.com不同,所以我在没有www的情况下再次注册我的网站,但它仍然无法正常工作.. 当我验证recaptcha_response_field和recaptcha_challenge_field时,值是正确的. 这是验证码检查器: require_once(recaptchalib.php'); $publickey = "not displayed"; //for security $privatekey = "not displayed"; //for security $error = null; if( $_POST ) { $arr = array('a' => $_POST['task'],'b' => $_POST['recaptcha_challenge_field'],'c' => $_POST['recaptcha_response_field']); if( trim($arr['a']) == 'captcha' ) { $resp = null; $error = null; $captcha_result = 'success'; $resp = recaptcha_check_answer( $privatekey,$_SERVER["REMOTE_ADDR"],$arr['b'],$arr['c'] ); if( $resp->error ){ $captcha_result = 'fail'; } echo $captcha_result; } } 这是HTML代码: <div id="captcha-div"> <script type="text/javascript"> var RecaptchaOptions = { tabindex: 1,theme: 'custom',custom_theme_widget: 'recaptcha_widget' }; </script> <div id="recaptcha_widget" style="display:none"><div id="recaptcha_image" style="width: 200px; height: 57px; "></div> <?php echo recaptcha_get_html($publickey,$error); ?> <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect. Try Again.</div> <span class="recaptcha_only_if_audio">Type what you hear</span> <input type="text" id="recaptcha_response_field" name="recaptcha_response_field"> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Kumuha ng larawang CAPTCHA</a></div> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0"></script> <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></div> <script type="text/javascript"> window.onload = function() { Recaptcha.focus_response_field(); } </script> <p id="captcha-error" style="color:red; font-weight:bold;"></p> </div> <div><a id="captcha-refresh" href="javascript:Recaptcha.reload()"></a></div> <div class="recaptcha_only_if_image"><a id="captcha-audio" href="javascript:Recaptcha.switch_type('audio')"></a></div> <div><a id="captcha-help" href="javascript:Recaptcha.showhelp()"></a></div> <div id="circle-submit"></div> 任何人都可以帮我解决这个问题吗? 谢谢, 解决方法
如
reCAPTCHA Support says:
不,这不会导致无效域.这意味着您没有正确地将recaptcha_challenge_field提交给服务器. 因此,请确保使用recapcha corectly呈现表单.查看this link. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |