我在我的网站上安装了google recaptcha V2,并且我想在google recaptcha完成时自动提交表单(没有按任何按钮),这是我的代码......
$secretKey='HIDDEN';
$responseKey=$_POST['g-recaptcha-response'];
$IP=$_SERVER['REMOTE_ADDR'];
$url="https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$IP";
$response=file_get_contents($url);
$response=json_decode($response);
if($response->success){
....execute some php
}
这是我的表格......
<form action="" method="post" class="Form" enctype="multipart/form-data">
<div class="g-recaptcha" data-sitekey="HIDDEN"></div>
</form>
感谢阅读,祝你有愉快的一天!
答案 0 :(得分:0)
添加像这样的回调
<div class="g-recaptcha" data-sitekey="your-key-here" data-callback="submitForm" ></div>
然后在您的javascript代码中包含类似的内容
<script>
var submitForm = function () {
$("#formID-goes-here").submit();
}
</script>