我最近在我的网站上安装了Google recaptcha,但尽管如此,我还是经常收到大量垃圾邮件(大约30个垃圾邮件,每周一次)。
我认为recaptcha非常可靠,所以我认为我的代码是问题,但我看不到。
这里的代码是为了得到你的意见。非常感谢您的建议
HTML
<head>
[...]
<script src='https://www.google.com/recaptcha/api.js?hl=en'></script>
[...]
</head>
<body>
[...]
<div class="g-recaptcha" data-sitekey="<PUBLIC_KEY>"></div>
[...]
</body>
PHP
if (isset($_POST["g-recaptcha-response"])) {
$reCaptcha = new ReCaptcha($secret_key);
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
if (isset($response) and $response != null and $response->success) {
send();
}
LIB
https://github.com/appleboy/ReCAPTCHA/blob/master/php/recaptchalib.php