/
/
home
/
u523034047
/
domains
/
psassociate.org
/
public_html
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.52
PHP 8.3.16
Dir:
/home/u523034047/domains/psassociate.org/public_html
Edit:
/home/u523034047/domains/psassociate.org/public_html/booking.php
<?php // Retrieve form data $name = $_POST['name']; $contact_no = $_POST['contact_no']; $email = $_POST['email']; $check_in_date = $_POST['check_in_date']; $check_out_date = $_POST['check_out_date']; $adults = $_POST['adults']; $children = $_POST['children']; $room_type = $_POST['room_type']; // Calculate number of nights stayed $check_in = strtotime($check_in_date); $check_out = strtotime($check_out_date); $number_of_nights = ($check_out - $check_in) / (60 * 60 * 24); // Define updated prices for each room type $room_prices = array( "Cottage" => 11499, "Standard Room" => 1799, "Deluxe Room" => 5999 ); // Calculate the total price and apply discounts if (array_key_exists($room_type, $room_prices)) { $base_price = $room_prices[$room_type] * $number_of_nights; if ($room_type == "Cottage") { $total_price = $base_price * 0.80; // 20% discount } elseif ($room_type == "Deluxe Room") { $total_price = $base_price * 0.85; // 15% discount } else { $total_price = $base_price; // No discount for Standard Room } } else { die("Invalid room type selected."); } // Compose email message for booking confirmation to the user $user_subject = "Booking Confirmation"; $user_message = "Dear $name,\n\n"; $user_message .= "Thank you for booking with us!\n\n"; $user_message .= "Booking Details:\n"; $user_message .= "Name: $name\n"; $user_message .= "Contact Number: $contact_no\n"; $user_message .= "Email: $email\n"; $user_message .= "Check-in Date: $check_in_date\n"; $user_message .= "Check-out Date: $check_out_date\n"; $user_message .= "Number of Nights Stayed: $number_of_nights\n"; $user_message .= "Adults: $adults\n"; $user_message .= "Children: $children\n"; $user_message .= "Room Type: $room_type\n"; $user_message .= "Total Price: Rs " . number_format($total_price, 2) . " + GST INR\n"; $user_message .= "\n\nWe look forward to welcoming you!\n\n"; // Send booking confirmation email to the user $user_headers = "From: booking@manalicottage.com" . "\r\n" . "Reply-To: booking@manalicottage.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); $user_email_sent = mail($email, $user_subject, $user_message, $user_headers); // Compose email message for booking notification to the admin $admin_subject = "New Booking"; $admin_message = "Name: $name\n"; $admin_message .= "Contact Number: $contact_no\n"; $admin_message .= "Email: $email\n"; $admin_message .= "Check-in Date: $check_in_date\n"; $admin_message .= "Check-out Date: $check_out_date\n"; $admin_message .= "Number of Nights Stayed: $number_of_nights\n"; $admin_message .= "Adults: $adults\n"; $admin_message .= "Children: $children\n"; $admin_message .= "Room Type: $room_type\n"; $admin_message .= "Total Price: Rs " . number_format($total_price, 2) . " + GST INR\n"; // Send booking notification email to the admin $to = "booking@manalicottage.com"; $headers = "From: $email" . "\r\n" . "Reply-To: $email" . "\r\n" . "X-Mailer: PHP/" . phpversion(); if (mail($to, $admin_subject, $admin_message, $headers)) { if ($user_email_sent) { echo "<div style='text-align: center; margin-top: 50px;'> <h2>Booking Successful!</h2> <p>Check your email for the booking confirmation.</p> <a href='https://manalicottage.com/' style='display: inline-block; margin-top: 20px; padding: 10px 20px; background-color: #007BFF; color: #FFF; text-decoration: none; border-radius: 5px; font-family: Montserrat, sans-serif;'>Return to Home</a> </div>"; } else { echo "<div style='text-align: center; margin-top: 50px;'> <h2>Booking Successful!</h2> <p>Confirmation email could not be sent to the user. Please contact support if you need assistance.</p> <a href='https://manalicottage.com/' style='display: inline-block; margin-top: 20px; padding: 10px 20px; background-color: #007BFF; color: #FFF; text-decoration: none; border-radius: 5px; font-family: Montserrat, sans-serif;'>Return to Home</a> </div>"; } } else { echo "<div style='text-align: center; margin-top: 50px;'> <h2>Error: Please try again later!</h2> </div>"; } ?>
Ukuran: 4.2 KB