step 1) go to google recaptcha website create key from here , which is require for third & fourth step.
step 2)add script between head tag- <script src="https://www.google.com/recaptcha/api.js"></script>
step 3)<div class="g-recaptcha brochure__form__captcha" data-sitekey="YOUR SITE KEY"></div>
step 4) just use below php code.
<?php
function reCaptcha($recaptcha){
$secret = "YOUR SECRET KEY";
$ip = $_SERVER['REMOTE_ADDR'];
$postvars = array("secret"=>$secret, "response"=>$recaptcha, "remoteip"=>$ip);
$url = "https://www.google.com/recaptcha/api/siteverify";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
}
$recaptcha = $_POST['g-recaptcha-response'];
$res = reCaptcha($recaptcha);
if($res['success']){
// go to page
}
?>
step 5) test it.
Nice , Good Information, I really like this blog
ReplyDeletegood.
ReplyDeletethanks to all, keep visit our blog https://learn-infyleaf.blogspot.com/
ReplyDelete