在没有插件 reCAPTCHA 的情况下验证用户的答案

发布于 2024-10-17 17:47:29 字数 844 浏览 2 评论 0原文

所以我试图让 recapcha 与我的表单一起工作。这是我的表单代码。

<form action="" method="post">
 <input type="text" name="text4" id="text4" style="width:400px" /><br/><br/>' . '<script type="text/javascript"
   src="http://www.google.com/recaptcha/api/challenge?k=XXXXXXXXXXXXXXXXXX">
</script>
<noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=XXXXXXXXXXXXXXXXXX"
       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><input type="button" value="Submit"/>

我正在尝试在没有插件的情况下使用验证码。显示它很容易,但我很难验证输入。有人知道如何在没有插件的情况下进行验证吗? 非常欣赏。

so i am trying to get recaptcha work with my form. This is the code i have for the form.

<form action="" method="post">
 <input type="text" name="text4" id="text4" style="width:400px" /><br/><br/>' . '<script type="text/javascript"
   src="http://www.google.com/recaptcha/api/challenge?k=XXXXXXXXXXXXXXXXXX">
</script>
<noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=XXXXXXXXXXXXXXXXXX"
       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><input type="button" value="Submit"/>

I'm trying to use the recaptcha without plugins. It was easy to make it show but I'm having a really hard time verify the input. Anyone know how to the the verify without plugin part?
Greatly appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情稳全场 2024-10-24 17:47:29

要使 reCaptcha 正常工作,您的服务器端代码应该类似于此处发布的内容:

如果不使用与此类似的解决方案,在任何服务器端都无法让 reCaptcha 工作语言。这是代码:

require_once('recaptchalib.php');
$privatekey = "your_private_key";

$resp = recaptcha_check_answer(
            $privatekey,
            $_SERVER["REMOTE_ADDR"],
            $_POST["recaptcha_challenge_field"],
            $_POST["recaptcha_response_field"]
        );

if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die( "The reCAPTCHA wasn't entered correctly. Go back and try it again." .
    "(reCAPTCHA said: " . $resp->error . ")" );
} else {
    // Your code here to handle a successful verification
}

Your server side code, to get reCaptcha to work, should be something similar to what's posted here:

There's no way to get reCaptcha to work, without using a solution similar to this, in any server-side language. Here is the code:

require_once('recaptchalib.php');
$privatekey = "your_private_key";

$resp = recaptcha_check_answer(
            $privatekey,
            $_SERVER["REMOTE_ADDR"],
            $_POST["recaptcha_challenge_field"],
            $_POST["recaptcha_response_field"]
        );

if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die( "The reCAPTCHA wasn't entered correctly. Go back and try it again." .
    "(reCAPTCHA said: " . $resp->error . ")" );
} else {
    // Your code here to handle a successful verification
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文