【问题标题】:Automatically send a form when google recaptcha V2 is completedgoogle recaptcha V2 完成后自动发送表单
【发布时间】:2017-09-09 17:22:31
【问题描述】:

我已经在我的网站上安装了 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>

感谢阅读,祝你有美好的一天!

【问题讨论】:

标签: javascript php jquery html recaptcha


【解决方案1】:

添加这样的回调

<div class="g-recaptcha" data-sitekey="your-key-here" data-callback="submitForm" ></div>

然后在您的 javascript 代码中包含类似的内容

<script>
var submitForm = function () {
    $("#formID-goes-here").submit();
}
</script>

【讨论】:

    猜你喜欢
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 2013-01-09
    相关资源
    最近更新 更多