kohjhjhصثقصثقصثقgdfgdg
Ele57885fddfgdfgfghgقفغفغفقhfg555434536
/
home
/
u542670534
/
domains
/
vadodaraservicecenter.com
/
public_html
/
Upload FileeE
HOME
<?php include("admin/config.php"); if ($_SERVER["REQUEST_METHOD"] == "POST") { // Enable error reporting temporarily for debugging error_reporting(E_ALL); ini_set('display_errors', 1); // Collect and validate inputs $name = trim($_POST['name']); $email = trim($_POST['email']); $contact = trim($_POST['contact']); $msg = trim($_POST['message']); // Validate fields if (!empty($name) && !empty($email) && !empty($contact) && !empty($msg)) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { die("Invalid email format."); } if (!preg_match('/^[0-9]{10}$/', $contact)) { die("Phone number must be 10 digits."); } // Use prepared statements to insert data securely $stmt = $db->prepare("INSERT INTO `contact`(`name`, `email`, `contact`, `message`) VALUES (?, ?, ?, ?)"); $stmt->bind_param("ssss", $name, $email, $contact, $msg); if ($stmt->execute()) { // Prepare the email // $to = "manavdant@gmail.com"; $subject = "Website Enquiry Detail"; $message = " <h4>Name: $name</h4> <h4>Email: $email</h4> <h4>Contact: $contact</h4> <h4>Message: $msg</h4>"; $headers = "From: $email \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html\r\n"; // Attempt to send the email // if (mail($to, $subject, $message, $headers)) { // echo "<script>alert('Your message has been sent successfully.'); window.location.href = document.referrer;</script>"; // } else { echo "<script>alert('Your message has been sent successfully.'); window.location.href = document.referrer;</script>"; // } } else { echo "Failed to save your message. Please try again."; } // Close the prepared statement $stmt->close(); } else { echo "All fields are required."; } } ?>