Php 有人能帮我设置reCAPTCHA服务器端吗?

Php 有人能帮我设置reCAPTCHA服务器端吗?,php,html,recaptcha,mail-form,Php,Html,Recaptcha,Mail Form,我是PHP新手,我正在尝试在PHP邮件表单中添加reCaptcha 代码与此类似: PHP: ` HTML: 名字 电子邮件* 数 梅萨吉奥* 使用谷歌易用的recaptcha, 你需要做的第一件事就是在Google recaptcha上注册你的网站 一旦提交,谷歌将为您提供以下两个信息 站点密钥 密钥 使用此代码将其集成到您的站点内的头标签中 <script src='https://www.google.com/recaptcha/api.js'></script&

我是PHP新手,我正在尝试在PHP邮件表单中添加reCaptcha
代码与此类似:

PHP:

`
HTML:


名字

电子邮件*

梅萨吉奥*


使用谷歌易用的recaptcha, 你需要做的第一件事就是在Google recaptcha上注册你的网站

一旦提交,谷歌将为您提供以下两个信息

  • 站点密钥
  • 密钥
使用此代码将其集成到您的站点内的头标签中

<script src='https://www.google.com/recaptcha/api.js'></script>

你能解释一下你在做什么吗?似乎验证码设备在那里-当你尝试它时会发生什么?是的,但是如果我不想要任何重定向,而只想发送电子邮件,我必须做什么?再次查看答案,并且重定向回是当recaptcha失败时@paolo.basso99ehm,我还有一个问题,因为我想添加一条错误消息,如:echo“♠ 电子邮件“不受邀请”;在//重定向回
<form method="post">
<p>name</p>
<input type="text" name="name" class="contactformimput"/>
<p>email*</p>
<input type="text" name="email" class="contactformimput"/>
<p>number</p>
<input type="text" name="number" class="contactformimput"/>
<p>Messaggio*</p>
<input type="text" name="message" onkeyup="adjust_textarea(this)" class="contactformimput" id="contactformtext">
<div class="g-recaptcha" data-sitekey="__MYPUBBLICKEY__"></div>
<div id="divcontactbutton">
<input type="reset" name="send" value="Resetta" class="button" id="resetmessage"/>
<input type="submit" name="send" value="Invia Messaggio" class="button" id="sendmessage"/>
</div>
</form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="SITE-KEY"></div>
 if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
    }
    if(!$captcha){
      echo '<h2>Check captcha .</h2>';
      exit;
    }
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR SECRET KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    if($response.success==false)
    {
        //redirect back
    }else
    {
       //your mail code 
    }