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 ""; } catch (Exception $e) { echo "Email could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } else { die("Invalid request."); } ?>