Current File : //var/www/html/common-footer-index.php |
<?php
ob_start();
//if(isset($_POST["recaptcha_response"])){
if(isset($_POST['recaptcha_response']) && !empty($_POST['recaptcha_response'])){
// Google reCAPTCHA API keys settings
$secretKey = '6LekLRwmAAAAANAnzcuo6jXJ0OuKLHHz2lKt14GZ';
// Get the user response token from the POST request
$responseToken = $_POST['recaptcha_response'];
// Make a POST request to the reCAPTCHA API
$recaptchaUrl = 'https://www.google.com/recaptcha/api/siteverify';
$recaptchaData = array(
'secret' => $secretKey,
'response' => $responseToken
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $recaptchaUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($recaptchaData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process the API response
$recaptchaResult = json_decode($response);
if ($recaptchaResult->success) {
// echo "Notnull";
if(isset($_POST['txtPageName']) == true && !empty($_POST['txtPageName'])){
// echo $_POST['txtPageName'];
$message = "Dear Admin, Enquiry Message from Vertex Power \r\n";
$message .= "--------------------------------------------------------------------------------\r\n";
$message .= "Name : ".$_POST['txtName']."\r\n";
$message .= "Email: ".$_POST['txtEmailid']."\r\n";
$message .= "Message: ".$_POST['txtMessage']."\r\n";
$message .= "--------------------------------------------------------------------------------\r\n";
date_default_timezone_set('Asia/Kolkata');
$to = "enquiry@vertexpower.co.in";
$from = "enquiry@vertexpower.co.in";
// $to = "swaragh.mailer@gmail.com";
// $from = "swaragh.mailer@gmail.com";
$subject = "Index Page Get in Touch With Us - Vertex Power - https://www.vertexpower.co.in/ - ".date("d F Y");
$headers = "From: Vertex Power - Index Page<noreply@vertexpower.co.in>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/plain;charset=UTF-8" . "\r\n";
if(mail($to, $subject, $message, $headers)== true){
echo "<script type='text/javascript'> alert('Thank you for sending your details, we will get back to you soon.');</script>";
header('Location:'.$_POST['txtPageName']);
exit(0);
}else{
echo "<script type='text/javascript'> alert('Something went wrong please try again.');</script>";
header('Location:'.$_POST['txtPageName']);
exit(0);
}
} else{
echo "<script type='text/javascript'> alert('Recaptcha went wrong, please try again.');</script>";
header('Location:'.$_POST['txtPageName']);
exit(0);
}
} else {
echo "<script> alert('ReCaptcha failed!!');</script>";
header('Location:'.$_POST['txtPageName']);
exit(0);
}
}
// }
ob_end_flush();
?>