From f7ecbcf33481da3e6f12d31cbda20eeb4effbf49 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Sun, 10 Dec 2023 19:11:11 +0530 Subject: [PATCH] (feat): implemented basic backend recapcha validation --- htdocs/core/handle_contact.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/core/handle_contact.php b/htdocs/core/handle_contact.php index b6bb565..c0973df 100644 --- a/htdocs/core/handle_contact.php +++ b/htdocs/core/handle_contact.php @@ -20,8 +20,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $message = form_input_filter($conn, $formData['message']); $recaptcha = form_input_filter($conn, $formData['recaptcha']); - $alertMessage = "Form Data Recived from ".$name; - $alertType = "success"; + if($name !== "" && $email !== "" && $message !== "") { + 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)); } }