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