Current Directory: /home/aissorg/public_html
Viewing File: /home/aissorg/public_html/pooja-online-reservation.php
<?php
ob_start(); // Add this line
session_start();
include 'admin/include/config.php'; // DB connection
$alertMessage = "";
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve & sanitize
$name = trim($_POST['name']);
$mobile = trim($_POST['mobile']);
$email = trim($_POST['email']);
$gender = trim($_POST['gender']);
$age = trim($_POST['age']);
$aadhar = trim($_POST['aadhar']);
$puja_type = trim($_POST['puja_type']);
$booking_date = trim($_POST['booking_date']);
$gotra = trim($_POST['gotra']);
$country = trim($_POST['country']);
$state = trim($_POST['state']);
$city = trim($_POST['city']);
$zip_code = trim($_POST['zip_code']);
$address = trim($_POST['address']);
$purpose = trim($_POST['purpose']);
// Validation
if (empty($name) || empty($mobile) || empty($email) || empty($gender) || empty($age) ||
empty($aadhar) || empty($puja_type) || empty($booking_date) || empty($gotra) ||
empty($country) || empty($state) || empty($city) || empty($zip_code) ||
empty($address) || empty($purpose)) {
$alertMessage = '<div class="alert alert-danger">All fields are required.</div>';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$alertMessage = '<div class="alert alert-danger">Invalid email format.</div>';
} elseif (!ctype_digit($mobile) || strlen($mobile) < 10 || strlen($mobile) > 15) {
$alertMessage = '<div class="alert alert-danger">Invalid mobile number.</div>';
} elseif (!ctype_digit($aadhar) || strlen($aadhar) != 12) {
$alertMessage = '<div class="alert alert-danger">Invalid Aadhar number. Must be 12 digits.</div>';
} elseif (!ctype_digit($zip_code)) {
$alertMessage = '<div class="alert alert-danger">Zip Code should contain only digits.</div>';
} else {
// Insert into database
$query = "INSERT INTO puja_booking
(name, mobile, email, gender, age, aadhar, puja_type, booking_date, gotra, country, state, city, zip_code, address, purpose)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if ($stmt = $con->prepare($query)) {
///$stmt->bind_param("sisssisssssssss", $name, $mobile, $email, $gender, $age, $aadhar, $puja_type, $booking_date, $gotra, $country, $state, $city, $zip_code, $address, $purpose);
$stmt->bind_param("sssssssssssssss", $name, $mobile, $email, $gender, $age, $aadhar, $puja_type, $booking_date, $gotra, $country, $state, $city, $zip_code, $address, $purpose);
if ($stmt->execute()) {
$last_id = $stmt->insert_id;
$_SESSION['booking_id'] = $last_id;
header("Location: mail.php");
exit();
} else {
$alertMessage = '<div class="alert alert-danger">Error processing your booking: ' . $stmt->error . '</div>';
}
/*if ($stmt->execute()) {
$last_id = $stmt->insert_id; // get last inserted booking ID
$_SESSION['booking_id'] = $last_id;
header("Location: mail.php");
exit();
}
else {
$alertMessage = '<div class="alert alert-danger">Error processing your booking.</div>';
}*/
$stmt->close();
} else {
$alertMessage = '<div class="alert alert-danger">Database error. Please try again later.</div>';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Online Puja Reservation</title>
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width height=device-height initial-scale=1.0 maximum-scale=1.0 user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta name="google-site-verification" content="" />
<meta name='og:title' content='All India Sai Samaj'>
<meta name='og:type' content='Sai Baba Temple - Mylapore'>
<meta name='og:url' content='https://aiss.org.in/'>
<meta name='og:image' content='https://aiss.org.in/demo/img/favicon.png'>
<meta name='og:site_name' content='All India Sai Samaj'>
<meta name='og:description' content='In 1941 Sri Narasimhaswamiji created an organization named “All India Sai Samaj" in Chennai to serve as the center of activities of Sai Mission. During his tour in various towns several people became his followers and with the guidance of Sri Swamiji they started Sai Samajams, which were called upasamajams affiliated to the main body All India Sai Samaj.'>
<link rel='canonical' href='https://aiss.org.in/pooja-online-reservation.php' />
<link rel="icon" href="img/favicon.png" type="image/x-icon">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Arimo:ital,wght@0,400..700;1,400..700&family=DM+Serif+Display&family=Noto+Serif:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/style.css" id="main-styles-link">
<link rel="stylesheet" href="css/about.css">
<link rel="stylesheet" href="css/custom.css">
<style>
.section-donate{
background: linear-gradient(to left,rgb(245, 222, 122),rgb(238, 238, 132), #e8e8a0);
}
.alert-success {
--bs-alert-color: var(--bs-success-text-emphasis);
--bs-alert-bg: #00d008;
--bs-alert-border-color: var(--bs-success-border-subtle);
--bs-alert-link-color: var(--bs-success-text-emphasis);
}
.spiritual-title {
position: relative;
display: inline-block;
text-align: center;
display: flex;
margin: 10px auto;
justify-content: space-evenly;
}
</style>
</head>
<body>
<div class="page">
<?php include('includes/header.php'); ?>
<section class="breadcrumbs-custom bg-image context-dark" style="background-image: url(img/common_banner.jpg);">
<div class="breadcrumbs-custom-inner">
<div class="container breadcrumbs-custom-container">
<div class="breadcrumbs-custom-main">
<h3 class="breadcrumbs-custom-title" style="color: #fff;">Online Puja Reservation</h3>
</div>
<ul class="breadcrumbs-custom-path">
<li><a href="./">Home</a></li>
<li class="active">Online Puja Reservation</li>
</ul>
</div>
</div>
</section>
<!-- Success Alert -->
<section class="section section-xs text-center bg-image context-dark" style="background-image: url('images/call-to-action.jpg')">
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-10 col-md-12">
<div class="box-cta-thin">
<h4 class="wow-outer" style="color:#fff;"><span class="wow slideInRight">Join us in making a difference — Become a donor today!</h4>
<div class="wow-outer button-outer"><a class="button button-primary button-winona wow slideInLeft" href="donate-now.php">Donate Now</a></div>
</div>
</div>
</div>
</div>
</section>
<div class="devotional-border"></div>
<section class="section section-lg oh">
<div class="container">
<div class="row">
<div class="col-md-12 wow slideInUp">
<?php
// Fetch online pooja content
$sql = "SELECT title, description, description2 FROM online_pooja WHERE is_active = 1 AND deleted_at IS NULL LIMIT 1";
$result = $con->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
?>
<div class="spiritual-title">
<img src="img/saibaba.png" class="mandala-bg" alt="mandala pattern">
<h1><?php echo htmlspecialchars($row['title']); ?></h1>
</div>
<?php
// Output the main description
?>
<p style="text-align:justify;" class="offset-top-20 wow-outer">
<span class="wow slideInDown" data-wow-delay=".05s"><?php echo nl2br(($row['description'])); ?></span>
</p>
<?php
} else {
echo "<p>No content available currently.</p>";
}
?>
</div>
<div class="col-md-8" style="margin-top:25px;">
<?php echo $alertMessage; ?>
<div class="donation-container" style="border-radius: 10px; padding: 20px; background: linear-gradient(150deg, #eed976, rgb(238, 194, 98), #fbf896, #d8a436, #e5c35b); border: 2px solid #d8a436;">
<form action="#" method="POST" id="donationForm">
<div class="row g-3">
<div class="col-md-4">
<label for="name">Name *</label>
<input class="form-control" id="name" type="text" name="name" required>
</div>
<div class="col-md-4">
<label for="mobile">Mobile *</label>
<input class="form-control" id="mobile" type="number" name="mobile" required>
</div>
<div class="col-md-4">
<label for="email">Email</label>
<input class="form-control" id="email" type="email" name="email" required>
</div>
</div>
<div class="row g-3 mt-2">
<div class="col-md-4">
<label for="amount">Gender</label>
<select class="form-control" name="gender" id="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
<div class="col-md-4">
<label for="kids">Age</label>
<input class="form-control" id="age" type="number" name="age" required>
</div>
<div class="col-md-4">
<label for="aadhar">Aadhar Number *</label>
<input class="form-control" id="aadhar" type="text" name="aadhar" required>
</div>
</div>
<div class="row g-3 mt-2">
<div class="col-md-4">
<label for="amount">Select Puja *</label>
<select class="form-control" name="puja_type" id="puja_type">
<option value="">Select Pooja</option>
<?php
// Get ID from URL if present
$selectedType = "";
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
$typeQuery = "SELECT title FROM upcoming_pooja WHERE id = $id LIMIT 1";
$typeResult = mysqli_query($con, $typeQuery);
if ($typeRow = mysqli_fetch_assoc($typeResult)) {
$selectedType = $typeRow['title'];
}
}
// Fetch all distinct types from active upcoming poojas
$query = "SELECT title FROM upcoming_pooja
WHERE is_active = 1
AND deleted_at IS NULL
ORDER BY type ASC";
$result = mysqli_query($con, $query);
while ($row1 = mysqli_fetch_assoc($result)) {
$type = $row1['title'];
$selectedAttr = ($type === $selectedType) ? 'selected' : '';
echo '<option value="' . htmlspecialchars($type) . '" ' . $selectedAttr . '>' . htmlspecialchars($type) . '</option>';
}
?>
</select>
</div>
<div class="col-md-4">
<label for="kids">Booking Date *</label>
<input class="form-control" id="booking_date" type="date" name="booking_date" required>
</div>
<div class="col-md-4">
<label for="aadhar">Gotra *</label>
<input class="form-control" id="gotra" type="text" name="gotra" required>
</div>
</div>
<div class="row g-3 mt-2">
<div class="col-md-4">
<label for="address">Address *</label>
<input class="form-control" id="address" name="address" required>
</div>
<div class="col-md-4">
<label for="country">Country</label>
<input class="form-control" id="country" type="text" name="country" required>
</div>
<div class="col-md-4">
<label for="state">State</label>
<input class="form-control" id="state" type="text" name="state" required>
</div>
</div>
<div class="row g-3 mt-2">
<div class="col-md-4">
<label for="city">City</label>
<input class="form-control" id="city" type="text" name="city" required>
</div>
<div class="col-md-4">
<label for="zip_code">Zip/Postal Code</label>
<input class="form-control" id="zip_code" type="text" name="zip_code" required>
</div>
<div class="col-md-4">
<label for="purpose">Purpose of Visit</label>
<textarea class="form-control" id="purpose" name="purpose" required></textarea>
</div>
</div>
<div class="text-center mt-4">
<button type="submit" class="btn btn-primary">Submit Now</button>
</div>
</form>
</div>
</div>
<div class="col-lg-4">
<!-- Profile Thin-->
<article class="profile-thin bg-color-theme">
<div class="profile-thin-main">
<span class="wow slideInDown" data-wow-delay=".05s"><?php echo nl2br(($row['description2'])); ?></span>
<a class="button button-sm button-primary-outline button-winona" href="donate-now.php">
<div class="content-original">Donate Now</div>
<div class="content-dubbed">Donate Now</div>
</a>
<!--<a class="button button-sm button-primary button-winona" href="online-pooja-booking.php">
<div class="content-original">Check Availability</div>
<div class="content-dubbed">Check Availability</div>
</a>-->
</div>
</article>
</div>
</div>
</div>
</section>
<?php include('includes/footer.php'); ?>
</div>
<div class="snackbars" id="form-output-global"></div>
<script src="js/core.min.js"></script>
<script src="js/script.js"></script>
<script>
// Auto-hide success message after 3 seconds
setTimeout(function() {
let successAlert = document.getElementById('successAlert');
if (successAlert) {
successAlert.style.display = 'none';
}
}, 3000); // Hide after 3 seconds
</script>
<script>
// Get today's date in YYYY-MM-DD format
const today = new Date().toISOString().split('T')[0];
// Set the minimum date to today (disables previous dates)
document.getElementById('booking_date').min = today;
</script>
</body>
</html>