· 7 years ago · Jan 12, 2019, 01:48 PM
1<form class="form" name="form" id="form" action="server/processForm.php" method="post" onsubmit="return validateForm();">
2 <div class="g-recaptcha" data-sitekey="an actual site key string"> </div>
3</form>
4
5<?php
6 $secretKey = "ITS A SECRET :P";
7 $responseKey = $_POST['g-recaptcha-response'];
8 $userIP = $_SERVER['REMOTE_ADDR'];
9
10 $recaptchaUrl = "https://www.google.com/recaptch/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$userIP";
11 $response = file_get_contents($recaptchaUrl);
12 $response = json_decode($response);
13
14 if ($response->success) {
15 echo "dice";
16 } else {
17 $error .='<br>You failed bot verification. Please go back and check the box...<br>';
18 }
19 ?>
20
21const recaptcha = grecaptcha.getResponse();
22if (recaptcha.length == 0) {
23 badValue.push("nBot Verification Failed! (Recaptcha) - Please check the box...");
24}
25if(badValue.length > 1) {
26 alert(badValue)
27 return(false);
28}