MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.142.200.102
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/ppcad7no/fastelevator.in/../snackpoint.co.nz/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/fastelevator.in/../snackpoint.co.nz/home-booking.php
<?php
    if ($_SERVER["REQUEST_METHOD"] === "POST") {
        if (isset($_POST['book-table'])) {
            $name = $_POST['name'];
            $phone = $_POST['phone'];
            $date = $_POST['date'];
            $time = $_POST['time'];
            $person = $_POST['person'];
            $currentTime = date("Y-m-d");
            $errors = array();
    
            // Validate input
            if (empty($name)) {
                $errors[] = "Name field is required.";
            } elseif (!preg_match('/^[a-zA-Z ]+$/', $name)) {
                $errors[] = "Name can only contain alphabets.";
            }
    
            if (empty($phone)) {
                $errors[] = "Phone field is required.";
            }
    
            // Sanitize input
            $name = filter_var($name, FILTER_SANITIZE_STRING);
            $phone = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);
            $person = filter_var($person, FILTER_SANITIZE_NUMBER_INT);
    
    if (empty($errors)) {
        $query = "INSERT INTO `tbl_booking` (`name`, `phone`, `bookin_date`, `no_of_travelers`, `message`, `date`) VALUES ( '$name', '$phone', '$date', '$person', '$time', '$currentTime')";
        $result = mysqli_query($db, $query) or die("Query unsuccessful");
        if ($result) {
            echo "<script>
                  window.alert('Successfully Submit! We will contact you soon');
                  window.location.href = '$wspath';
                  </script>";
            mysqli_close($db);
        }
    }
 }
}
?>
    <section class="reservation pb-lg-0 pq-bg-dark-color">
		<div class="pq-section-title-style-1 text-center">
	   	   	<span class="pq-section-sub-title">Make a Reserve</span>
	        <h5 class="pq-section-title"> Book A table On time</h5>
		</div>
		<div class="container">
			<div class="row align-items-baseline">
				<div class="col-lg-6 col-md-12">
					<div class="pq-reservation-img">
						<img class="img-fluid" src="images/reservation.png" alt="reservation">
					</div>
				</div>
				<div class="col-lg-6 col-md-12 align-self-start mt-4 mt-lg-0">
					<div class="pq-reservation-main-form">
						<form class="pq-applyform" novalidate method="POST" action="<?php $_PHP_SELF?>">
							<div class="row">
								<div class="col-lg-12">
									<input type="text" size="40" name="name" placeholder="Your Name" required>
                                    <?php if (isset($errors) && in_array("Name field is required.", $errors)) { ?>
                                        <p class="error">Name field is required.</p>
                                    <?php } elseif (isset($errors) && in_array("Name can only contain alphabets.", $errors)) { ?>
                                        <p class="error">Name can only contain alphabets.</p>
                                    <?php } ?>
								</div>
								<div class="col-lg-12">
									<input type="text" name="phone" size="40" placeholder="Your Phone" minlength="6" maxlength="12" onkeypress="return isNumberKey(event)" pattern=".{6,12}" onpaste="return false;" required>
                                    <?php if (isset($errors) && in_array("Phone field is required.", $errors)) { ?>
                                        <p class="error">Phone field is required.</p>
                                    <?php } ?>
								</div>
								<div class="col-lg-12">
									<input type="text" name="person" size="40" placeholder="Persons" required>
								</div>
								<div class="col-lg-12">
									<input type="date" name="date" placeholder="dd-mm-yyyy" min="<?php echo date('Y-m-d'); ?>">
								</div>
								<div class="col-lg-12">
									<input type="time" name="time" size="40" placeholder="Time">
								</div>
								<div class="col-lg-12 text-center">
									<button class="pq-button pq-button-flat" name="book-table" type="submit">
										<span class="pq-button-text">Book Table</span>
									</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</section>

MMCT - 2023