kohjhjhصثقصثقصثقgdfgdg
Ele57885fddfgdfgfghgقفغفغفقhfg555434536
/
home
/
u542670534
/
domains
/
dentalstudiobydrtanushree.com
/
public_html
/
Upload FileeE
HOME
<?php include("admin/config.php"); if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Set response headers for JSON header('Content-Type: application/json'); // Collect and validate inputs $name = !empty($_POST['full_name']) ? trim($_POST['full_name']) : null; $email = !empty($_POST['email']) ? trim($_POST['email']) : null; $contact = !empty($_POST['contact_no']) ? trim($_POST['contact_no']) : null; $subject = !empty($_POST['subject']) ? trim($_POST['subject']) : null; $msg = !empty($_POST['message']) ? trim($_POST['message']) : null; // Check if all fields are filled if ($name && $email && $contact && $subject && $msg) { // Use prepared statements for secure database insertion $stmt = $db->prepare("INSERT INTO `contact`(`name`, `email`, `contact`, `subject`, `message`) VALUES (?, ?, ?, ?, ?)"); $stmt->bind_param("sssss", $name, $email, $contact, $subject, $msg); if ($stmt->execute()) { // Prepare the email $to = "dr.tanushree05@gmail.com"; $subjectMail = "Website Enquiry Detail"; $message = "<h4>Name: $name</h4><h4>Email: $email</h4><h4>Contact: $contact</h4><h4>Subject: $subject</h4><h4>Message: $msg</h4>"; $headers = "From: $email\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html\r\n"; // Simulate mail sending $mailSent = mail($to, $subjectMail, $message, $headers); if ($mailSent) { echo json_encode(["status" => 1, "message" => "Mail has been sent successfully."]); } else { echo json_encode(["status" => 0, "message" => "Failed to send email."]); } } else { echo json_encode(["status" => 0, "message" => "Database insertion failed."]); } $stmt->close(); } else { echo json_encode(["status" => 0, "message" => "All fields are required."]); } } else { echo json_encode(["status" => 0, "message" => "Invalid request method."]); } ?>