find all your recaptcha info and statistics
when you register your recaptcha, you will get 2 codes.
site key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
secret key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
add the code to your:
<script async defer src="https://www.google.com/recaptcha/api.js" ></script>
<div style="padding-left: 12%; width: 100%" class="g-recaptcha" data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"></div>
- Then, make sure that your apache configuracion allows to use iframe, specifically the Content-Security-Policy
Then add the validating code to your internal "logics" page, I do this in PHP.
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
//echo "$response: ".$response."\n\n\n\n\n";
//echo "$data: ".$data."\n\n\n\n\n";
echo "</br>captcha: validating";
if(isset($data->success) AND $data->success==true)
DO WHATEVER YOU WANT YOUR CODE TO DO!