I was using the old ReCaptcha on my site but just upgrading to the new ReCaptcha i've 3-4 different tutorials but it keeps failing and giving the fail error.
HTML
<form method="POST" action="/feedback_sent/" enctype="multipart/form-data">
<table border="0" width="100%" cellpadding="4" cellspacing="4" height="67">
<tr>
<td width="30%" height="30">Name</td>
<td width="70%" height="30">
<p><input type="text" name="name" size="41"></p>
</td>
</tr>
<tr>
<td valign="top" width="30%" height="27">Feedback</td>
<td width="70%" height="27">
<textarea rows="8" name="feedback" cols="57"></textarea></td>
</tr>
<tr>
<td valign="top" width="30%" height="27"></td>
<td width="70%" height="27">
<div class="g-recaptcha" data-sitekey="My_Key"></div>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit" value="Submit" name="B1"></td>
</tr>
</table>
</form>
PHP:
$secret="---my key---";
$response=$_POST["g-recaptcha-response"];
$verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");
$captcha_success=json_decode($verify);
if ($captcha_success->success==false) {
echo "<p>You are a bot! Go away!</p>";
}
else if ($captcha_success->success==true) {
echo "<p>You are not not a bot!</p>";
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…