Php GoogleRecaptcha根本不支持简单实现

Php GoogleRecaptcha根本不支持简单实现,php,html,Php,Html,我的html表单如下所示: <form method="post" action="mail.php" name="contactform" id="contactform"> <div class="input-wrap"><i class="fa fa-user-plus" aria-hidden="true"></i><input name="name" type="text" id="name" class="inputForm

我的html表单如下所示:

<form method="post" action="mail.php" name="contactform" id="contactform">
  <div class="input-wrap"><i class="fa fa-user-plus" aria-hidden="true"></i><input name="name" type="text" id="name"  class="inputForm2" onClick="this.select()" value="Name" ></div>
  <div class="input-wrap"><i class="fa fa-envelope" aria-hidden="true"></i><input name="email" type="text" id="email" onClick="this.select()" value="E-mail" ></div>
  <textarea name="comments" id="comments" onClick="this.select()">Message</textarea>
  <div class="g-recaptcha" data-sitekey="--- SITE KEY FROM GOOGLE ---" style="float: right"></div>
  <textarea name="g-recaptcha-response" id="g-recaptcha-response" style="display: none"></textarea>
  <button type="submit" id="submit"><span>Send Message</span></button>
</form>
$url = 'https://www.google.com/recaptcha/api/siteverify';
$secretkey = "--- SECRET KEY FROM GOOGLE ---";
$response = file_get_contents($url."?sectret=".$secretkey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);

if(isset($data->success) AND $data->success == false){
    //error
    exit;
}else{
    //success
}
我就是不知道问题出在哪里!如果有人能帮我? 如果我回显$data,无论是否检查验证码表单,我总是收到{success:false,错误代码:[缺少输入响应,缺少输入机密]}。我不知道为什么在显示的错误中给了我,还有,当我给他密钥时,丢失的输入密钥…

您这里有一个输入错误:

$response = file_get_contents($url."?sectret=".$secretkey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
应该是:

$response = file_get_contents($url."?secret=".$secretkey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);

是的,你是对的!这发生在你累的时候。。。非常感谢。现在,丢失的输入秘密错误被消除,但是丢失的输入响应和成功:false仍然存在@你甚至可以做一个var_dump$_POST?这就是我得到的:array3{[name]=>string6-dfgfhg[email]=>string16fhgjghjh@gtgt.ol[评论]=>string14 nghhgjhkjlkjlj}你觉得@FMashiro怎么样?为什么g-recaptcha-response丢失,而表单没有将其发送到mail.php?是否使用g-recaptcha-response硬编码div?