-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
34 lines (29 loc) · 924 Bytes
/
Copy pathsubmit.php
File metadata and controls
34 lines (29 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
header('Content-Type: application/json');
$secretKey = "6LeR5qIrAAAAACchpxuwsF-2PIOh2Lq-whf3u_Um";
$captcha = $_POST['captcha'];
if (!$captcha) {
echo json_encode(['success' => false, 'message' => 'Captcha is missing']);
exit;
}
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = [
'secret' => $secretKey,
'response' => $captcha
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
];
$context = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$responseKeys = json_decode($verify, true);
if ($responseKeys["success"]) {
echo json_encode(['success' => true, 'message' => 'Form submitted successfully']);
} else {
echo json_encode(['success' => false, 'message' => 'Captcha verification failed']);
}
?>