Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript google recaptcha V2完成后自动发送表单_Javascript_Php_Jquery_Html_Recaptcha - Fatal编程技术网

Javascript google recaptcha V2完成后自动发送表单

Javascript google recaptcha V2完成后自动发送表单,javascript,php,jquery,html,recaptcha,Javascript,Php,Jquery,Html,Recaptcha,我已经在我的网站上安装了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&

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


谢谢你的阅读,祝你度过愉快的一天

添加这样的回调

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

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

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

var submitForm=函数(){
$(“#formID在此显示”).submit();
}

使用计时器并持续ping服务器以查看验证码是否已验证。如果核实,只需提交表格。可能的副本