HTML

Paste this snippet before the closing </head> tag on your HTML template:

<script src='https://www.google.com/recaptcha/api.js'></script>

Paste this snippet at the end of the <form> where you want the reCAPTCHA widget to appear:

<div class="g-recaptcha" data-sitekey="{site key}"></div>

 

PHP Code

if($_SERVER[“REQUEST_METHOD”] === “POST”)
{
//form submitted

//check if other form details are correct

//verify captcha
$recaptcha_secret = “{secret key}”;
$response =file_get_contents(“https://www.google.com/recaptcha/api/siteverify?secret=”.$recaptcha_secret.“&response=”.$_POST[‘g-recaptcha-response’]);
$response = json_decode($response, true);
if($response[“success”] === true)
{
echo “Logged In Successfully”;
}
else
{
echo “You are a robot”;
}
}

,
Trackback

no comment untill now

Sorry, comments closed.