- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用带有重新验证码的 php 联系表单,但不知道应该使用什么值:
$client_captcha_response = $_POST['g-recaptcha-response'];
将在 g-recaptcha-response
中有,因为我试图通过另一个验证代码页面收集它,但每次我提交时都为 g-recaptcha-response
提供了不同的值
我的提交 ID 表单显示空白页。
HTML 端代码:
<form method="post" action="contactform.php">
<label>Your Name (required):</label>
<input name="name" type="text" placeholder="Enter your name here">
<label>Email Address (required):</label>
<input name="email" type="email" placeholder="Enter your email address here">
<label>Your Message (required):</label>
<textarea name="message" placeholder="Write your message here"></textarea>
<div class="g-recaptcha" data-sitekey="6LfTVfgSAAAAADvdpWzYkifBXTmJ8ohokl_lIKgH"></div>
<input id="submit" name="submit" type="submit" value="Submit Form">
</form>
PHP 端代码:
<?php
$your_secret = "<Secret key>";
$client_captcha_response = $_POST['g-recaptcha-response'];
$user_ip = $_SERVER['REMOTE_ADDR'];
$captcha_verify = open_https_url("https://www.google.com/recaptcha/api/siteverify?secret=$your_secret&response=$client_captcha_response&remoteip=$user_ip");
$captcha_verify_decoded = json_decode($captcha_verify);
if(!$captcha_verify_decoded->success)
die('DIRTY ROBOT');
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = $_POST['human'];
$from = 'From: My Website';
$to = 'myemail@gmail.com';
$subject = 'Request Form';
$body = "Name: $name \n E-Mail: $email \nMessage:\n$message";
if ($_POST['submit']) {
if ($email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>You have successfully submitted your information to PS4RS. Subscribers to our mailing list will begin to periodically receive updates.</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p><p><input type="button" value="Go Back" onclick="history.back(-1)" class="goback" /></p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p><p><input type="button" value="Go Back" onclick="history.back(-1)" class="goback" /></p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p><p><input type="button" value="Go Back" onclick="history.back(-1)" class="goback" /></p>';
}
}
?>
最佳答案
这是我的代码运行没有问题:
客户端:
<div class="g-recaptcha" data-sitekey="PUBLIC_KEY"></div>
服务器端:
if (isset($_POST['g-recaptcha-response'])) {
$captcha = $_POST['g-recaptcha-response'];
$privatekey = "SECRET_KEY";
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => $privatekey,
'response' => $captcha,
'remoteip' => $_SERVER['REMOTE_ADDR']
);
$curlConfig = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data
);
$ch = curl_init();
curl_setopt_array($ch, $curlConfig);
$response = curl_exec($ch);
curl_close($ch);
}
$jsonResponse = json_decode($response);
if ($jsonResponse->success == "true")
doSomething();
else
doSomeOtherThing();
工作 here ! :)
关于带有 recaptcha 的 PHP 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29770124/
我在我的一种表单中集成了 reCAPTCHA v3。在 onload 中,右下角有一个生成的 token 和谷歌验证码标志。但是当我提交表单时,在控制台中会显示一个错误,“错误:不存在 reCAPTC
是我还是 recaptcha 图像无法翻译成除 EN 以外的其他语言? 我有 它仍然是英文的。这是故意的吗? 最佳答案 对于 reCAPTCHA 2. 一段时间过去了 这是你的cdn链接看最后,hl参
我正在尝试按照 https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally 中的说明在全局范围内使用 r
我们在我们的网站之一中集成了隐形 recaptcha。每当我们提交表单时,它就会自动提交。 我在一些谷歌小组中读到,在边缘浏览器上访问时我们会遇到挑战。但对我们来说,它是自动提交的。 测试隐形reca
我目前使用的是假的开发域而不是 localhost在我的本地机器上,因为我有多个要在本地管理的网站。 Google reCAPTCHA 无法识别我的域,并给我以下错误:ERROR: Invalid d
reCAPTCHA 需要公钥和私钥才能在网站中实现。它还需要 reCAPTCHA key ,具体取决于网站。这背后的原因是什么?公钥和私钥是否会影响 reCAPTCHA 中显示的文字?我知道我可以将公
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭13 年前。 Improve th
我目前使用隐形recaptcha,如果它认为用户是机器人,它会自动显示一个验证码。 现在有了 Recaptcha v3,我很难理解它应该如何使用。 它返回一个分数,但是如果分数很低,这可能表明用户是机
我希望,如果用户(或漫游器)重复做同样的事情,那么Recaptcha v3的得分会下降,但是事实并非如此。 这是从我的日志中摘录的内容,当我在正在构建的网站上登录时尝试使用不同的密码时,该日志是其中的
我有新的隐形 recaptcha 工作正常,但它把徽章放在左下角或右下角。您可以使用“data-badge='inline'”覆盖它,并将其拉入表单中。谷歌对如何实际移动它非常含糊。您无法隐藏它,因为
我的网站正在使用 Google reCAPTCHA 控件,但我听说它被阻止了 中国,反正我看到有人报告说将 API 更改为 https://www.recaptcha.net在中国工作? Anyone
我面临以下情况:当用户点击提交按钮时,应用会禁用该按钮。然后,当 ReCaptcha 的回调函数被调用时,我可以再次启用该按钮。但是如果用户关闭验证窗口我怎么知道然后再次启用我的按钮? 最佳答案 我在
在 reCAPTCHA v3 文档中,它说 reCAPTCHA works best when it has the most context about interactions with your
我正在尝试在我的网站上呈现 google reCaptcha。我去了google reCaptcha admin ,设置标签,并添加两个域:一个是localhost,另一个是mydomain.com。
我已登录我的 Google 帐户,并导航到 reCaptcha 设置页面。但它显示的只是创建新 reCaptcha 帐户的表单。 我想我曾经能够为我的不同域找到我以前的帐户设置,但现在似乎没有任何地方
ReCaptcha v3 将不再提供验证码,而是依靠浏览器指纹识别和谷歌可以获得的有关您的其他信息。 这是一个测试:https://recaptcha-demo.appspot.com/recaptc
google recaptcha 创建了一个没有可访问性属性的 textarea,例如 aria-label。这导致 recaptcha 无法通过 Siteimprove 进行可访问性扫描。 我已经尝
我正在我的一个网站上实现 reCAPTCHA,并且我已经成功实现了它。它工作正常。有时仅通过单击“我不是机器人”才能完成 reCAPTCHA,但有时它会显示图像网格以选择正确的图像并完成验证码。 我只
我已经在我的网站上实现了 reCaptcha,但每当我测试它时,我都会尝试 3-5 次才能成功。我认为我的用户不会喜欢这个。我注意到有些网站有诸如“2 + 2 是什么?”之类的问题。类似的东西同样有效
我在 Angular+Spring MVC 应用程序中使用 Google reCaptcha 进行用户登录。我想知道谷歌是否对其每天(或周/月/年)支持的点击次数有任何限制。 最佳答案 首先,我建议您
我是一名优秀的程序员,十分优秀!