mirror of
https://github.com/neosubhamoy/neosubhamoy-portfolio.git
synced 2025-12-20 02:19:34 +05:30
(feat): implemented basic backend recapcha validation
This commit is contained in:
@@ -20,8 +20,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$message = form_input_filter($conn, $formData['message']);
|
$message = form_input_filter($conn, $formData['message']);
|
||||||
$recaptcha = form_input_filter($conn, $formData['recaptcha']);
|
$recaptcha = form_input_filter($conn, $formData['recaptcha']);
|
||||||
|
|
||||||
$alertMessage = "Form Data Recived from ".$name;
|
if($name !== "" && $email !== "" && $message !== "") {
|
||||||
$alertType = "success";
|
if($recaptcha !== "") {
|
||||||
|
$secret = '';
|
||||||
|
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $secret . '&response=' . $recaptcha);
|
||||||
|
$responseData = json_decode($verifyResponse);
|
||||||
|
|
||||||
|
if($responseData->success) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode(array("alert" => $alertMessage, "alertType" => $alertType));
|
echo json_encode(array("alert" => $alertMessage, "alertType" => $alertType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user