'Sonography-Landing Page',
"Name" => $name,
"Email" => $email,
"Phone" => $phone,
"Message" => strip_tags($textarea_message),
"UserAgent" => $device . " (" . $browser . ")",
"IP Address" => $ipAddress,
"Geo Location" => $location,
];
// reCAPTCHA
$recaptcha_secret = '6LeCnR0sAAAAAFfOqc5qOwCf96TndBPRCEUd5ivU';
$recaptcha_response = $_POST['g-recaptcha-response'] ?? '';
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_data = [
'secret' => $recaptcha_secret,
'response' => $recaptcha_response
];
$recaptcha_options = [
'http' => [
'method' => 'POST',
'content' => http_build_query($recaptcha_data)
]
];
$recaptcha_context = stream_context_create($recaptcha_options);
$recaptcha_result = json_decode(file_get_contents($recaptcha_url, false, $recaptcha_context));
if ($recaptcha_result && $recaptcha_result->success && $recaptcha_result->score >= 0.5) {
// Send to Google Sheets
$webhook_url = "https://script.google.com/macros/s/AKfycbxr4mE-xftZscDgslutrQUNBFQhh-Qi5-Ni6QGNV6wDrHnzHpjEtq0CdGHEngbA8JVo/exec";
$options = [
"http" => [
"header" => "Content-type: application/json",
"method" => "POST",
"content" => json_encode($formdata)
]
];
$context = stream_context_create($options);
@file_get_contents($webhook_url, false, $context);
// Email to Admin
$to = "imagingworld9@gmail.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html;charset=UTF-8\r\n";
$headers .= "From: noreply@imagingworld.in\r\n";
$headers .= "Bcc: leads@clientsnow.co.in\r\n";
$body = <<
New Sonography Inquiry - Imaging World
|
New Inquiry Received
A user has submitted a new inquiry from Imaging World website.
|
| Name |
{$name} |
| Email |
{$email} |
| Phone |
{$phone} |
| Message |
{$message_html} |
| IP Address |
{$ipAddress} |
| Geo Location |
{$location} |
| Device |
{$device} |
| Browser |
{$browser} |
|
|
© Imaging World - Sonography & Diagnostics, Ahmedabad
|
|
HTML;
// Anti-spam validation
if (strpos(strtolower($textarea_message), "http") !== false || empty($input_name) || empty($input_phone) || strpos(strtolower($input_name), "http") !== false || !empty($bot)) {
header("Location: /");
exit();
}
// Send main mail
if (mail($to, "Contact Inquiry", $body, $headers)) {
// Thank-you mail to user
if (!empty($email)) {
$user_subject = "Thank You for Contacting Imaging World";
$user_headers = "MIME-Version: 1.0\r\n";
$user_headers .= "Content-type:text/html;charset=UTF-8\r\n";
$user_headers .= "From: Imaging World \r\n";
$user_body = <<
Thank You – Imaging World
|
Thank You, {$name}!
We’ve received your inquiry. Our medical team will reach out shortly to assist you.
|
|
Here are the details you submitted:
| Name |
{$name} |
| Email |
{$email} |
| Phone |
{$phone} |
| Message |
{$message_html} |
|
Why Choose Imaging World?
Advanced Diagnostics | Accurate Reports | Expert Radiologists | Patient-Friendly Care
|
|
© Imaging World | Lead System & Email Template Designed by
Clients Now Technologies
|
|
HTML;
@mail($email, $user_subject, $user_body, $user_headers);
}
header("Location: thankyou.php");
exit();
} else {
header("Location: /");
exit();
}
} else {
header("Location: /");
exit();
}
}