如何发送POST请求以使我的reCAPTCHA表单生效?

时间:2015-07-06 17:37:37

标签: php recaptcha

我想为我老板的联系表格实施Google reCAPTCHA button。我已将必要的代码集成到html中,但我遇到了第2步服务器端集成的问题:

Google Instructions

这是我测试代码的网页:http://agentboris.com/listings/85bloorstreeteast-book.php

有人可以解释如何编写第2步的代码以及我应该在哪里集成它(即是否需要将其编码到网页文件或PHP表单脚本文件中)?

1 个答案:

答案 0 :(得分:1)

您可以通过这种方式执行服务器端验证

  // grab recaptcha library
 require_once "recaptchalib.php";
 $reCaptcha = new ReCaptcha($secret);

 // if submitted check response
 if ($_POST["g-recaptcha-response"]) {
  $response = $reCaptcha->verifyResponse(
    $_SERVER["REMOTE_ADDR"],
    $_POST["g-recaptcha-response"]
  );
 }
相关问题