问题描述
我已经从Google Developers示例复制了reCaptcha代码,输入了我的网站密钥,它适用于所有3种方法。
我的编码经验可以追溯到vb6。
我想要做的就是使用reCaptcha来验证人是否正在使用我的联系页面并阻止发送按钮工作,直到reCaptcha验证了ihem。
我使用Dreamweaver创建我的网站。
I've copied the reCaptcha code from Google Developers example, entered my site key and it works for all 3 methods.
My coding experience dates back to vb6.
All i want to do is use reCaptcha to verify that a Human is using my contact page and prevent the send button from working until reCaptcha has verified ihem.
I use Dreamweaver to create my site.
推荐答案
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var opt_widget_id;
var onloadCallback = function() {
opt_widget_id = grecaptcha.render('html_element', {
'sitekey' : 'put your key here'});
};
</script>
</head>
<body>
<form action="response.php" method="POST">
<input type="text" name="myname" value="" placeholder="Enter your name">
<div id="html_element"></div>
<br>
<input type="submit" value="Submit">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
</body>
</html>
index.html页面将接受一个名为myname的用户输入,用于发布到response.php,如下所示:
The "index.html" page will accept a user's input called "myname" for posting to "response.php" as shown:
<?php
if(empty(
)
点击提交按钮时, myname和他的验证码响应g-recaptcha-response将被发布到response.php,它将检查它是否为空(这意味着它已被验证)。如果g-recaptcha-response为空,它将被重定向回index.html。
要了解有关网络如何工作的更多信息,请查看以下内容:
[]。
PS实际上,Ajax将是最合适的技术。但我认为信息超载。
When the submit button is clicked, the "myname" and his captcha response "g-recaptcha-response" will be posted over to the response.php which will check that it is not empty (which means it has been verified). If the "g-recaptcha-response" is empty, it will be redirected back to the index.html.
To learn more about how the web works, check this out:
PHP 5 Form Handling[^].
P.S. Actually, Ajax will be the most suitable technology to use here. But I consider it information overload.
这篇关于我如何简单地验证Recaptcha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!