%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/www/website_6031bb72/ |
Upload File : |
<?php
include "config.php";
$query_website=mysqli_query($conn,"SELECT * FROM `system_settings` WHERE `id`=1");
$rows_website=mysqli_fetch_array($query_website);
$isArabic = isset($_COOKIE['ar']);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
header('Content-Type: application/json');
$response = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = mysqli_real_escape_string($conn, $_POST['name']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$phone = mysqli_real_escape_string($conn, $_POST['phone']);
$message = mysqli_real_escape_string($conn, $_POST['message']);
$receive_date = date('Y-m-d H:i:s');
if(empty($name) || empty($email) || empty($phone) || empty($message)){
$response['status'] = "error";
$response['message'] = $isArabic ? 'جميع الحقول مطلوبة.' : 'All fields are required.';
echo json_encode($response);
exit;
}
$email_config=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM email_setting WHERE id=1"));
$host=$email_config['host'];
$port=$email_config['port'];
$username=$email_config['email'];
$password=$email_config['password'];
if(isset($_COOKIE['ar'])) {
$website_name = $rows_website['website_name_ar'];
} else {
$website_name = $rows_website['website_name'];
}
// template heading
$name_h = $isArabic ? 'اسم' : 'Name';
$country_h = $isArabic ? 'دولة' : 'Country';
$email_h = $isArabic ? 'معرف البريد الإلكتروني' : 'Email ID';
$phone_h = $isArabic ? 'هاتف' : 'Phone';
$appointment_h = $isArabic ? 'تاريخ ووقت الموعد' : 'Appointment Date & Time';
$service_name_h = $isArabic ? 'اسم الخدمة' : 'Service Name';
$message_h = $isArabic ? 'رسالة' : 'Message';
$receive_date_h = $isArabic ? 'تاريخ الاستلام' : 'Receive Date';
$subject = $isArabic ? 'استفسار الاتصال' : 'Contact enquiry';
$altbody = $isArabic ? 'تم إرسال استفسارك بنجاح' : 'Your enquiry sent successfully';
$successmessage = $isArabic ? 'تم إرسال استفسار الاتصال بنجاح!' : 'Contact enquiry send successfully!';
$errormessage1 = $isArabic ? '❌ خطأ في البريد الإلكتروني:' : '❌ Mail Error:';
$errormessage2 = $isArabic ? 'حدث خطأ في قاعدة البيانات. يرجى المحاولة مرة أخرى.' : 'Database error. Please try again.';
$errormessage3 = $isArabic ? 'طلب غير صالح.' : 'Invalid request.';
$email_temp = '
<table style="border: solid 2px #DDEEEE; border-collapse: collapse; border-spacing: 0; font: normal 14px Roboto, sans-serif;">
<thead>
<tr>
<th style="background-color: #DDEFEF; border: solid 1px #DDEEEE; color: #336B6B; padding: 10px; text-align: left; text-shadow: 1px 1px 1px #fff;">
'.$name_h.'
</th>
<th style="background-color: #DDEFEF; border: solid 1px #DDEEEE; color: #336B6B; padding: 10px; text-align: left; text-shadow: 1px 1px 1px #fff;">
'.$email_h.'
</th>
<th style="background-color: #DDEFEF; border: solid 1px #DDEEEE; color: #336B6B; padding: 10px; text-align: left; text-shadow: 1px 1px 1px #fff;">
'.$phone_h.'
</th>
<th style="background-color:#DDEFEF; border:solid 1px #DDEEEE; color: #336B6B; padding: 10px; text-align: left; text-shadow: 1px 1px 1px #fff;">
'.$receive_date_h.'
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: solid 1px #DDEEEE; color: #333; padding: 10px; text-shadow: 1px 1px 1px #fff;">' . $name . '</td>
<td style="border: solid 1px #DDEEEE; color: #333; padding: 10px; text-shadow: 1px 1px 1px #fff;">' . $email . '</td>
<td style="border: solid 1px #DDEEEE; color: #333; padding: 10px; text-shadow: 1px 1px 1px #fff;">' . $phone . '</td>
<td style="border: solid 1px #DDEEEE; color: #333; padding: 10px; text-shadow: 1px 1px 1px #fff;">' . $receive_date . '</td>
</tr>
<tr>
<td colspan="8" style="border: solid 1px #DDEEEE; color: #333; padding: 10px; text-shadow: 1px 1px 1px #fff;">' . nl2br($message) . '</td>
</tr>
</tbody>
</table>';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
// $mail->SMTPDebug = 2;
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = $port;
$mail->CharSet = 'UTF-8';
$mail->setFrom($username, $website_name);
$mail->addAddress($username);
$mail->addAddress($email);
$mail->addAddress('info@alshifamedicaltour.com');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $email_temp;
$mail->AltBody = $altbody;
$mail->send();
} catch (Exception $e) {
$response['status'] = "error";
$response['message'] = $errormessage1 . " " . $mail->ErrorInfo;
echo json_encode($response);
exit;
}
$insert = mysqli_query($conn, "INSERT INTO `enquiry_tbl` (name, email, phone, message, enquiry_type, receive_date) VALUES ('$name', '$email', '$phone', '$message','2', '$receive_date')");
if ($insert) {
$response['status'] = "success";
$response['message'] = $successmessage;
} else {
$response['status'] = "error";
$response['message'] = $errormessage2;
}
} else {
$response['status'] = "error";
$response['message'] = $errormessage3;
}
echo json_encode($response);
exit;
?>