############################# In header #############################
<script src='https://www.google.com/recaptcha/api.js'></script>
############################# By Submit Button #############################
<div class="g-recaptcha" data-sitekey="ayyyayyayhsTAAAAAOaH8nt_1z00zu6BGxVZ87"></div>
############################# In process form #############################
<?php
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<br><br><h2>Please check the the captcha form.</h2>';
}
$secretKey = "ayyyayyayhsTAAAAAOaH8nt_1z00zu6BGxVZ87";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<br><br><h2>Spammers are not welcome here!</h2>';
} else {
echo '';
}
?>