Google reCaptcha v2
<!--
Step 1:
https://www.google.com/recaptcha/admin/create
-->
<!-- Step 2: This file -->
<html>
<head>
<title>Google reCaptcha v2 Demo</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<h1>Google reCAPTHA Demo</h1>
<form id="comment_form" action="form-post.php" method="post">
...
<div class="g-recaptcha" data-sitekey="SITE_KEY"></div>
<input type="submit" name="submit" value="Submit"><br><br>
</form>
</body>
</html>
<!-- Step 3: form-post.php -->
<?php
// $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRET_KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
// if($response.success==true)
// {
// echo '<h2>Thanks for posting comment.</h2>';
// }
if(isset($_POST['g-recaptcha-response'])){
$captcha = $_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the captcha.</h2>';
exit;
}
else {
echo '<h2>Thanks for posting.</h2>';
}
?>