function invisibleCaptcha($captcha) {
$data = array(
'secret' => "SECRET",
'response' => $captcha
);
$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($verify, CURLOPT_POST, true);
curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($verify);
$response = json_decode($response);
if($response->success === true){
return true;
}
else{
return false;
}
}
if(invisibleCaptcha($_POST['captcha-response'])){
// captcha onaylandı
}<form method="post" action="">
<div class="form-group">
<input type="text" name="name" class="form-control" />
</div>
<div class="form-group">
<div class="g-recaptcha" data-sitekey="SITEKEY" data-badge="invisible" data-size="invisible" data-callback="setResponse"></div>
<input type="hidden" id="captcha-response" name="captcha-response" />
</div>
</form>