Google ReCaptcha - 缺少输入回复

时间:2016-01-23 01:35:11

标签: javascript php recaptcha

我有一个联系表单,我想通过使用谷歌recaptcha避免机器人。我收到错误:遗漏 - 输入 - 响应,我不知道为什么我认为我正在遵循正确的步骤。请帮帮我。

以下是代码:

<form method="post" id="ContactForm" action="contact2.php">    
<input placeholder="Name" type="text" name="name" id="name" >                       
<input placeholder="E-Mail" type="email" name="contactemail"  id="contactemail">            
<input placeholder="Organization Name" type="text" name="orgname" id="orgname" >
<input placeholder="Subject" type="text" name="sub" id="sub" class="StyleTxtField inputBg" style="background: url(images/subject.png) no-repeat left center; background-color:white; " required>
<textarea rows=5 cols=200 placeholder="Your e-mail" name="body" id="body" ></textarea>

<div class="g-recaptcha" data-sitekey="..."></div>
<span id="wrongcap" class="wrongInput">*Wrong !</span>

<button type="submit" id="button"  class="send">Send</button>       

</form>

在这里我如何检查contact2.php

    $url= 'https://www.google.com/recaptcha/api/siteverify';
    $privatekey='...';
    $respnose= file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-respnose']);
    $data = json_decode($respnose);
    echo $respnose;
    echo "-1";
    if(isset($data->success) AND $data->success==true){
       echo "0";
    }else{
       echo "1";
    }

0 个答案:

没有答案