· 9 years ago · Oct 20, 2016, 12:24 PM
1$sitekey = "";
2$secretkey = "";
3$error = "";
4
5if ($_SERVER["REQUEST_METHOD"] == "POST") {
6 if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
7 $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secretkey.'&response='.$_POST['g-recaptcha-response']);
8 $responseData = json_decode($verifyResponse);
9 if($responseData->success):
10 // là m j` đó........
11 else:
12 $error .= "Captcha chưa được xác thực đúng !<br>";
13 endif;
14 else:
15 $error .= "Bạn chưa xác thực captcha !<br>";
16 exit;
17 endif;
18}