Google ReCaptcha使用php验证

Google ReCaptcha使用php验证,recaptcha,Recaptcha,我试着像这样验证ReCaptcha,但它不起作用。它不允许发送电子邮件,当点击“我不是机器人”时,什么也不会发生 if(trim($_POST['getResponse']) == '') { $hasError = true; } else { $getResponse = trim($_POST['getResponse']); } 我的ReCaptcha PHP代码 <div class="form-group"> <div class="g-r

我试着像这样验证ReCaptcha,但它不起作用。它不允许发送电子邮件,当点击“我不是机器人”时,什么也不会发生

if(trim($_POST['getResponse']) == '') {
    $hasError = true;
} else {
    $getResponse = trim($_POST['getResponse']);
}
我的ReCaptcha PHP代码

<div class="form-group">
    <div class="g-recaptcha" data-sitekey="mykeyhere"></div>
    <span class="help-block" style="display: none;">Kinnita,et sa ei ole robot.</span>
</div>

<span class="help-block" style="display: none;">Sisesta turvakood.</span>
</div>

<div class="actions">
    <input type="submit" value="<?php _e('Saada', 'bootstrapwp'); ?>" name="submit" id="submitButton" class="btn btn-primary" title="Saada!" />
    <input type="reset" value="<?php _e('Tühjenda väljad', 'bootstrapwp'); ?>" class="btn btn-danger" title="Tühjenda väljad." />
</div>

金妮塔,还有一个机器人。
西塞斯塔·图瓦库德。

好的,用这个代码工作

     if(isset($_POST['g-recaptcha-response'])){
    $captcha=$_POST['g-recaptcha-response'];
  }
  if(!$captcha){
    echo '<h2>Please check the the captcha form.</h2>';
    exit;
  }
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=key&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
        if($response.success==false)
        {
          echo '<h2>You are spammer ! Get the @$%K out</h2>';
        }else
        {
          echo '<h2>Thanks for posting comment.</h2>';
        }
if(isset($\u POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
如果(!$captcha){
echo“请检查验证码表。”;
出口
}
$response=文件\u获取\u内容(“https://www.google.com/recaptcha/api/siteverify?secret=key&response=“$captcha.”&remoteip=“.$”服务器['REMOTE\u ADDR']);
if($response.success==false)
{
echo“你是垃圾邮件发送者!把@$%K拿出来”;
}否则
{
echo“感谢您发表评论”;
}
现在唯一的问题是错误和成功消息显示在另一个页面上,如何在表单中显示这些错误和成功消息