PHP 中奇怪的 reCaptcha 错误
我在网站上实施 reCaptcha 时遇到问题。
我按照这里的教程进行操作:http://code.google.com/apis/recaptcha /docs/php.html 并仅实现了带有错误消息的基本 reCaptcha。
下面是我在表单提交到的文件中使用的一些自定义代码:
if (!$resp->isValid) {
$_SESSION['badLoginCount'] += 1;
$_SESSION['incorrect-captcha'] = true;
$_SESSION['incorrect-captcha-error'] = $resp->error;
header ('Location: ../../signin.php');
exit;
}
如果用户键入不正确的 reCaptcha,页面将重定向并按预期显示错误。然而,当用户输入正确的 reCaptcha 时,isValid 仍然评估为 FALSE 并运行此分支,但是 $resp->error 不包含任何内容,这使得调试几乎不可能。
以前有人遇到过这个吗?我在网上找不到任何东西。
I am having a problem with implementing a reCaptcha on my website.
I followed the tutorial here: http://code.google.com/apis/recaptcha/docs/php.html and implemented just a basic reCaptcha with an error message.
Below is some custom code I use in the file which the form is submitted to:
if (!$resp->isValid) {
$_SESSION['badLoginCount'] += 1;
$_SESSION['incorrect-captcha'] = true;
$_SESSION['incorrect-captcha-error'] = $resp->error;
header ('Location: ../../signin.php');
exit;
}
If the user types the incorrect reCaptcha, the page redirects and an error is shown as expected. However when a user enters the correct reCaptcha, isValid still evaluates to FALSE and runs this branch, however $resp->error contains nothing, and this has made it almost impossible to debug.
Has anyone come across this before? I can't find anything online.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个快速而简单的解决方法是检查
$resp->error
是否为空。A quick and hacky workaround would be to check if
$resp->error
is empty instead.