Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
menders
/
cars
/
js
:
contactDone.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if ($_SERVER["REQUEST_METHOD"] === "POST") { // ---------- Helpers ---------- function clean($v) { return trim(htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8')); } function sendHtmlMail($to, $subject, $html, $fromEmail = 'no-reply@civiccodes.com', $fromName = 'Chawla Green Motors') { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type:text/html;charset=UTF-8\r\n"; $headers .= "From: {$fromName}<{$fromEmail}>\r\n"; $headers .= "Reply-To: info@chawlagreenmotors.com\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; return mail($to, $subject, $html, $headers); } // ---------- Get & sanitize inputs ---------- $name = clean($_POST['name'] ?? ''); $email = clean($_POST['email'] ?? ''); $subject1 = clean($_POST['subject'] ?? ''); $message = clean($_POST['message'] ?? ''); // Basic validation if ($name === '' || $email === '' || $subject1 === '' || $message === '') { echo "<script>alert('Please fill all required fields.'); window.history.back();</script>"; exit; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "<script>alert('Please enter a valid email address.'); window.history.back();</script>"; exit; } // ---------- Admin email (to company) ---------- $adminSubject = "Request Received For Two Wheelers!"; $adminMsg = " <html><head><title></title></head><body> <table border='0' width='100%' align='center'> <tr><td colspan='2' align='center'> <img src='https://chawlagreenmotors.com/images/logo2.png' width='140' alt='Chawla Green Motors'> </td></tr> </table> <table border='0' width='100%' align='center'> <tr><td colspan='2' align='left'> <span style='font-size:18px;color:#000;'>Dear Sir,<br> An information request has been submitted with details as below:</span> </td></tr> </table> <table border='1' width='60%' align='left' cellpadding='8' cellspacing='0' style='border-collapse:collapse;'> <tr> <td><b>Name</b></td> <td>{$name}</td> </tr> <tr> <td><b>Email</b></td> <td>{$email}</td> </tr> <tr> <td><b>Request For</b></td> <td>TWO WHEELER VEHICLES</td> </tr> <tr> <td><b>Subject</b></td> <td>{$subject1}</td> </tr> <tr> <td><b>Message</b></td> <td>{$message}</td> </tr> </table> <div style='clear:both;'></div> <table border='0' width='100%' align='left'> <tr><td> <br><br> <p style='font-size:16px;color:#000;'>Regards,<br>Chawla Green Motors</p> <img src='https://chawlagreenmotors.com/images/logo2.png' width='100' alt='Chawla Green Motors'> </td></tr> </table> </body></html>"; // Company recipients (edit if needed) $companyRecipients = [ "info@chawlagreenmotors.com", "syedzeeshanali38@gmail.com" ]; $adminOk = true; foreach ($companyRecipients as $r) { $sent = sendHtmlMail($r, $adminSubject, $adminMsg); if (!$sent) $adminOk = false; } // ---------- Customer confirmation email ---------- $customerSubject = "We’ve received your request – Chawla Green Motors"; $customerMsg = " <html><head><title></title></head><body> <table border='0' width='100%' align='center'> <tr><td colspan='2' align='center'> <img src='https://chawlagreenmotors.com/images/logo2.png' width='140' alt='Chawla Green Motors'> </td></tr> </table> <table border='0' width='100%' align='center'> <tr><td colspan='2' align='left'> <span style='font-size:16px;color:#000;'> Dear {$name},<br><br> Thank you for contacting <b>Chawla Green Motors</b>.<br> We’ve received your request for and our team will get back to you shortly.<br><br> <b>Your submitted details:</b><br> Subject: {$subject1}<br> Message: {$message}<br><br> Regards,<br> Chawla Green Motors<br> <a href='https://chawlagreenmotors.com' style='color:#000;'>chawlagreenmotors.com</a> </span> </td></tr> </table> </body></html>"; // send confirmation to user $customerOk = sendHtmlMail($email, $customerSubject, $customerMsg); // ---------- Final response ---------- if ($adminOk) { // Even if customer mail fails, still confirm request submission echo "<script>alert('Thank you! Your request has been received. A confirmation email has been sent to your email address.'); window.location.href='index.html';</script>"; } else { echo "<script>alert('Your request was submitted, but we could not notify our team by email. Please call us or try again.'); window.location.href='index.html';</script>"; } exit; } ?>