https://developers.google.com/recaptcha/docs/verify与验证码v2和表单提交
if(isset($_POST['submit'])){
$recaptchaResponse = $_POST['g-recaptcha-response'];
$secretKey = 'MYKEY';
$request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$recaptchaResponse);
if(!strstr($request,"false")){
echo '<div class="notification error clearfix"><p><strong>Attention!</strong> You didnt complete the captcha.</p></div>';
exit();
那么php文件邮件的休息形式挣扎,但它只是发送反正就算你不完成的ReCaptcha。基本上,如果JSON返回一个错误,我希望在这难道不发送,并会显示错误
而且,这里是从页面的形式,如果有帮助,我已经大概做了错事有太多...
<form method="POST" action="post.php" name="contactform" id="contactform" class="container">
<fieldset>
<div class="form-field grid-half">
<label for="name">Name</label>
<span><input type="text" name="name" id="name" /></span>
</div>
<div class="form-field grid-half">
<label for="email">Email</label>
<span><input type="email" name="email" id="email" /></span>
</div>
<div class="form-field grid-full">
<label for="message">Message</label>
<span><textarea name="message" id="message"></textarea></span>
</div>
<div class="form-field grid-full">
<div class="g-recaptcha" data-sitekey="MYKEY"></div>
</div>
</fieldset>
<div class="form-click grid-full">
<span><input type="submit" name="submit" value="Submit" id="submit" /></span>
</div>
<div id="alert" class="grid-full"></div>
</form>
为什么要使用Captcha?在我们公司,我们进行了一项研究,发现约有30%的人只需填写验证码即可。也许看看蜜罐技术加上一些良好的服务器端验证和技术,比如跟踪用户完成textarea的总体链接的表单和内容所需的时间。如果你这样做,你将不再需要验证码,用户会很高兴。阅读它可能会有所帮助:http:// solutionfactor。net/blog/2014/02/01/honeypot-technique-fast-easy-spam-prevention/ – w3shivers 2014-12-03 06:48:54