加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – recaptcha总是返回false

发布时间:2020-12-13 22:46:18 所属栏目:PHP教程 来源:网络整理
导读:我的recaptcha有问题.问题是它总是返回false意味着它表示验证码失败了.即使键入了正确的单词. 一切都是最新的,使用最新的库并三重检查代码和公钥/私钥. 问题我相信在这里…… require_once('recaptchalib.php'); $privatekey = "***************************
我的recaptcha有问题.问题是它总是返回false意味着它表示验证码失败了.即使键入了正确的单词.

一切都是最新的,使用最新的库并三重检查代码和公钥/私钥.

问题我相信在这里……

require_once('recaptchalib.php');
          $privatekey = "************************************";
    $resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
                  $error_string .= '<center>The reCAPTCHA wasnt entered correctly. Go back and try it again.</center><br />';
        }

我按照这个例子,所以我看不出有什么问题.已经好几天了!

https://developers.google.com/recaptcha/docs/php

客户代码:

require_once('recaptchalib.php');
    $publickey = "**********************"; // you got this from the signup page
    echo recaptcha_get_html($publickey);

在$resp变量上执行了var转储并得到了这个

object(ReCaptchaResponse)#2 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol" }

还做了一个var_dump recaptcha响应字段,得到了:

NULL

var dump post …

array(7) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" }

var转储请求…

array(10) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" ["PHPSESSID"]=> string(26) "4e79u2fdgrrufvb79einufcmq6" ["cprelogin"]=> string(2) "no" ["cpsession"]=> string(65) ":fX5Z1aWfbsgjGfgb3b3J7koo3Y58y5ntgM6k8GTdrQ4YAcqaywAKnD7PRiayfXv3" }

解决方法

谢谢你们的支持.我发现这个问题决定发布,如果有人在将来遇到这个问题.

我的表格在我的桌子里面,就像

<table><form>...</form></table>

显然表格应先是表格!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读