D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
u193541357
/
domains
/
racysanitaryware.com
/
public_html
/
1
/
dev
/
Filename :
submit_dealer_form.php
back
Copy
<?php ini_set('display_errors', 1); error_reporting(E_ALL); // Include PHPMailer files require 'phpmailer/Exception.php'; require 'phpmailer/PHPMailer.php'; require 'phpmailer/SMTP.php'; // Use PHPMailer classes from the namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $required_fields = [ 'fullname', 'email', 'contact', 'address1', 'address2', 'city', 'state', 'pincode', 'dealer-name', 'dealer-address1', 'dealer-address2', 'dealer-city', 'dealer-state', 'dealer-pincode', 'dealer-contact', 'invoice-number', 'invoice-date', 'product-details', 'quantity' ]; foreach ($required_fields as $field) { if (empty($_POST[$field])) { echo 'error'; exit; } } if (!isset($_FILES['upload-invoice']) || $_FILES['upload-invoice']['error'] != 0) { echo 'error'; exit; } $file = $_FILES['upload-invoice']; $allowed_types = ['application/pdf', 'image/jpeg']; if (!in_array($file['type'], $allowed_types)) { echo 'error'; exit; } $upload_dir = 'uploads/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0777, true); } $file_path = $upload_dir . basename($file['name']); move_uploaded_file($file['tmp_name'], $file_path); // Admin email details $admin_email = 'care.racysanitarywares@gmail.com'; $subject = 'New Warranty Claim Submission'; $message = "New Warranty Claim submission:\n"; foreach ($_POST as $key => $value) { $message .= "$key: $value\n"; } // Use PHPMailer for sending email $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; // Your SMTP Host $mail->SMTPAuth = true; $mail->Username = 'care.racysanitarywares@gmail.com'; // Your Username $mail->Password = 'cddzvvtoppqoohha'; // Your App Password $mail->SMTPSecure = 'ssl'; // Use SSL encryption $mail->Port = 465; // SMTP Port // Admin email $mail->setFrom('rajradhanpura7@gmail.com', 'Warranty Claims'); $mail->addAddress($admin_email); // Admin address $mail->Subject = $subject; $mail->Body = $message; // Attach file $mail->addAttachment($file_path, basename($file['name'])); // Send email to Admin $mail->send(); } catch (Exception $e) { echo "Error sending admin email: {$mail->ErrorInfo}"; exit; } // Send confirmation email to user $user_email = $_POST['email']; $user_subject = 'Thank you for your submission'; $user_message = 'Thank you for submitting your details. We will get back to you soon!'; $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; // Your SMTP Host $mail->SMTPAuth = true; $mail->Username = 'care.racysanitarywares@gmail.com'; // Your Username $mail->Password = 'cddzvvtoppqoohha'; // Your App Password $mail->SMTPSecure = 'ssl'; // Use SSL encryption $mail->Port = 465; // SMTP Port // User email $mail->setFrom('rajradhanpura7@gmail.com', 'Warranty Claims'); $mail->addAddress($user_email); // User's email address $mail->Subject = $user_subject; $mail->Body = $user_message; // Send email to user $mail->send(); } catch (Exception $e) { echo "Error sending user email: {$mail->ErrorInfo}"; exit; } echo 'success'; } else { echo 'error'; } ?>