Booking online system php

Online Hotel Reservation System in PHP/MySQLi

This System entitled Online Hotel Reservation System in PHP/MySQLi is designed for Justine’s Guest House Online Hotel Reservation System.

The project is an open-source hotel reservation system in PHP and MySQLi that has an online booking system PHP MySQL. It allows the guest to look for rooms with equivalent rates.

The system can store and retrieve the data of guests and their transactions. And this method conjointly integrated within the booking of hotel rooms.

The Hotel Reservation System in PHP Projects has significant features of the admin facet of this method have the potential to verify the booking, area reservation, and cancellation of transactions. Add, Update, and delete the area, Amenities, Room Types, User, View comments, and issue completely different reports.

Читайте также:  Get text document html

online hotel reservation system in php and mysql source code

Hotel Reservation system setup guide

    Extract the downloaded file then copy it inside your root directory.

You can log in into the admin side using this account:
username:[email protected]password:1234

If you have any questions or suggestions, please feel free to contact me on facebook or simply leave a comment below.

Download the source code of the Hotel Reservation System in PHP Projects here. justines

Источник

Simple Venue Booking With PHP MySQL (Free Download)

Welcome to a tutorial on how to create a simple venue booking system with PHP and MySQL. I am pretty sure there are plenty of such “booking” or “reservation” systems out there already. So, here’s one that is slightly different – A barebones version that you can build upon, without any third-party frameworks. Read on!

TABLE OF CONTENTS

PHP MYSQL VENUE BOOKING

All right, let us now get into the details of building a venue booking system with PHP and MySQL.

PART 1) THE DATABASE

1A) VENUE TABLE

-- (A) VENUE CREATE TABLE `venue` ( `venue_id` bigint(20) NOT NULL, `venue_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `venue` ADD PRIMARY KEY (`venue_id`), ADD KEY `venue_name` (`venue_name`); ALTER TABLE `venue` MODIFY `venue_id` bigint(20) NOT NULL AUTO_INCREMENT;

Feel free to add more fields as required – Opening days and hours, number of rooms, capacity, etc…

1B) BOOKING TABLE

-- (B) BOOKING CREATE TABLE `booking` ( `book_id` bigint(20) NOT NULL, `venue_id` bigint(20) NOT NULL, `book_date` date DEFAULT NULL, `book_slot` varchar(32) DEFAULT NULL, `book_name` varchar(255) NOT NULL, `book_email` varchar(255) NOT NULL, `book_tel` varchar(60) NOT NULL, `book_notes` text DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `booking` ADD PRIMARY KEY (`book_id`), ADD KEY `venue_id` (`venue_id`), ADD KEY `book_date` (`book_date`), ADD KEY `book_slot` (`book_slot`), ADD KEY `book_name` (`book_name`), ADD KEY `book_email` (`book_email`), ADD KEY `book_tel` (`book_tel`); ALTER TABLE `booking` MODIFY `book_id` int(11) NOT NULL AUTO_INCREMENT;

Next, a table to store all the booking entries.

  • book_id Primary key and auto-increment.
  • venue_id Foreign key. The venue being booked.
  • book_date Date booked for.
  • book_slot Time slot booked for. This is an open text field, you can pretty much define any time slots you want.
  • book_name book_email book_tel Name, email, and telephone of the person who booked the venue.
  • book_notes Optional notes for the booking.

Once again, feel free to add or remove the fields that you want to capture.

1C) DUMMY DATA

-- (C) DUMMY ENTRIES INSERT INTO `venue` (`venue_id`, `venue_name`) VALUES (NULL, 'Room A'), (NULL, 'Room B'), (NULL, 'Room C');

Finally, just 3 dummy rooms to kickstart the demo.

PART 2) PHP BOOKING LIBRARY

pdo = new PDO( "mysql:host=". DB_HOST .";dbname=". DB_NAME .";charset=". DB_CHARSET, DB_USER, DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_NAMED ]); > // (B) DESTRUCTOR - CLOSE DATABASE CONNECTION function __destruct () < $this->pdo = null; $this->stmt = null; > // (C) HELPER FUNCTION - RUN SQL QUERY function query ($sql, $data=null) < $this->stmt = $this->pdo->prepare($sql); $this->stmt->execute($data); > // (D) GET ALL VENUES function getVenue () < $this->query("SELECT * FROM `venue`"); $venue = []; while ($r = $this->stmt->fetch()) < $venue[$r["venue_id"]] = $r["venue_name"]; >return $venue; > // (E) GET BOOKING FOR THE DAY function getBooking ($id, $day="") < // (E1) DEFAULT TO TODAY if ($day=="") < $day = date("Y-m-d"); >// (E2) GET ENTRIES $booking = []; $this->query( "SELECT * FROM `booking` WHERE `venue_id`=? AND `book_date`=?", [$id, $day] ); while ($r = $this->stmt->fetch()) < $booking[$r["book_slot"]] = $r; >return $booking; > // (F) SAVE BOOKING function save ($id, $date, $slot, $name, $email, $tel, $notes="") < // (F1) CHECKS & RESTRICTIONS // @TODO - ADD YOUR OWN RULES & REGULATIONS HERE // MUST BE REGISTERED USER TO BOOK? // MAX # OF RESERVATIONS ALLOWED? // USER CAN ONLY BOOK X DAYS IN ADVANCE? // USER CAN ONLY BOOK A MAX OF X SLOTS WITHIN Y DAYS? // (F2) DATABASE ENTRY $this->query( "INSERT INTO `booking` (`venue_id`, `book_date`, `book_slot`, `book_name`, `book_email`, `book_tel`, `book_notes`) VALUES (. )", [$id, $date, $slot, $name, $email, $tel, $notes] ); // (F3) CONFIRMATION // @TODO - UP TO YOU TO COMPLETE. THIS WILL JUST SEND AN EMAIL TO THE USER. $subject = "Booking Received"; $message = "Thank you, we have received your request and will process it shortly."; @mail($email, $subject, $message); return true; > > // (G) DATABASE SETTINGS - CHANGE THESE TO YOUR OWN! define("DB_HOST", "localhost"); define("DB_NAME", "test"); define("DB_CHARSET", "utf8mb4"); define("DB_USER", "root"); define("DB_PASSWORD", ""); // (H) NEW BOOKING OBJECT $_BOOK = new Booking();

Now that we have established the database, we will create a PHP library to work with it. This looks massive at first, but keep calm and look carefully.

  • (A & B) When is $_BOOK = new Booking() created, the constructor will automatically connect to the database. The destructor will close the database connection.
  • (C) A helper function to run an SQL query.
  • (D to F) The “actual” booking functions.
    • getVenue() Get all available venues.
    • getBooking() Get all bookings for the selected venue and date.
    • save() Save a booking entry. Complete this function on your own – Do your own checks, and the “post-process”.

    PART 3) PHP BOOKING AJAX HANDLER

    getBooking($_POST["id"], $_POST["date"])); break; // (B) SAVE case "save": echo $_BOOK->save( $_POST["venue"], $_POST["date"], $_POST["slot"], $_POST["name"], $_POST["email"], $_POST["tel"], $_POST["notes"]) ? "OK" : $_BOOK->error; break; >>

    Before we proceed with the HTML booking page, let us create an AJAX endpoint. How this page work is very simple, just send:

    For example, to check for the booking for a specified venue and date, just send $_POST[«req»] = «check» , $_POST[«id»] = N , and $_POST[«date»] = «YYYY-MM-DD» .

    PART 4) HTML BOOKING PAGE

    4A) THE HTML

    getVenue(); // get venues $mindate = date("Y-m-d"); // min selectable date // $mindate = date("Y-m-d", strtotime("+2 days")); ?>    
    Venue & Time
    Date " value="">
Contact Person
Email
Telephone

Well, this “massive HTML form” is just… an HTML form. Feel free to add/remove the fields that you need.

4B) JAVASCRIPT – CHECK SLOT AVAILABILITY

var book = < // (A) CHECK SLOT AVAILABILTY check : () =>< // (A1) GET FORM ELEMENTS let venue = document.getElementById("book_venue"), date = document.getElementById("book_date"), slot = document.getElementById("book_slot"), go = document.getElementById("book_go"); // (A2) DISABLE SLOTS & SUBMIT slot.disabled = true; go.disabled = true; // (A3) CHECK SLOT AVAILABILTY WITH SERVER let data = new FormData(); data.append("req", "check"); data.append("id", venue.value); data.append("date", date.value); // (A4) FETCH fetch("3-ajax-booking.php", < method: "POST", body: data >) .then(res => res.json()) .then(booked => < // (A4-1) ALL SLOTS BOOKED FOR THE DAY if (Object.keys(booked).length>=2) < slot.innerHTML = ""; > // (A4-2) SLOTS AVAILABLE else < slot.innerHTML = ""; for (let s of ["AM", "PM"]) < if (booked[s]==undefined) < let o = document.createElement("option"); o.innerHTML = s; o.value = s; slot.appendChild(o); >> slot.disabled = false; go.disabled = false; > >); >, // . >; window.addEventListener("load", book.check);

Remember the AJAX handler? Whenever the user changes the venue and date, we will have to fire a fetch request to the AJAX handler to check for slot availability and update the HTML interface accordingly.

4C) JAVASCRIPT – SUBMIT FORM

// (B) SUBMIT BOOKING save : () => < // (B1) FORM DATA let data = new FormData(document.getElementById("bookForm")); data.append("req", "save"); // (B2) FETCH SUBMIT FORM document.getElementById("book_go").disabled = true; fetch("3-ajax-booking.php", < method: "POST", body: data >) .then(res => res.text()) .then(txt => < if (txt == "OK") < alert("@TODO - REDIRECT TO 'THANK YOU' OR DO SOMETHING ELSE"); location.reload(); >else < alert(txt); >>) .finally(() => < document.getElementById("book_go").disabled = false; >); // (B3) PREVENT FORM SUBMIT return false; >

The last step of the process, submit the form to the server… Do whatever you need to after that – Redirect the user to a “thank you” page, process payment, or whatever.

DOWNLOAD & NOTES

Here is the download link to the example code, so you don’t have to copy-paste everything.

SUPPORT

600+ free tutorials & projects on Code Boxx and still growing. I insist on not turning Code Boxx into a «paid scripts and courses» business, so every little bit of support helps.

EXAMPLE CODE DOWNLOAD

Click here for the source code on GitHub gist, just click on “download zip” or do a git clone. I have released it under the MIT license, so feel free to build on top of it or use it in your own project.

That’s all for the tutorial, and here is a small section on some extras and links that may be useful to you.

EXTRA) CSV BOOKING REPORT

getVenue() as $vid=>$v) < $book = $_BOOK->getBooking($vid, $today); if (count($book)>0) < foreach ($book as $slot=>$b) fputcsv($fout, [$v, $b["book_date"], $slot, $b["book_name"], $b["book_email"], $b["book_tel"], $b["book_notes"]]); > > fclose($fout);

How do we use the library to create reports? Here is a small example that will fetch all the reservations for the day, and generate a CSV report with it.

COMPLETE YOUR OWN SYSTEM

  • Admin, user, and login system – See links below.
  • Date range and time slots –
    • If you are offering hourly slots, just change AM/PM to slots such as “1000-1100” and “1100-1200”.
    • If you are offering a range of dates, it will make sense to change the database table to “start date” and “end date”.
    • For both date range and time slot, it will be “start date”, “start slot”, “end date”, and “end slot”.
    • As above, add a “capacity” field to the venue table.
    • Change the getBooking() function to count the available capacity.
    • Change the HTML form 4a-book.php to select rooms (if any) – Check out the “seat reservation” link below, just use it as “room reservation”.

    Yes, it is impossible to create a “one size fits all” system, I cannot offer free consultations to everyone too – The rest is up to you.

    COMPATIBILITY CHECKS

    Works on all modern “Grade A” browsers.

    THE END

    Thank you for reading, and we have come to the end. I hope that it has helped you to better understand, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!

    Источник

    Project: Online Hotel Booking System using PHP and MySQL with Source Code

    online hotel booking system project

    About Online Hotel Booking System using PHP MySQL Project Free Download

    Complete Online Hotel Booking System using PHP MySQL Free Download is a clean, premium, and modern booking script. It is responsive on literally any screen size, this way you can worry less about the interface, and focus on what is important. Use this system, and create something amazing!

    Core Features of Complete Online Hotel Booking System

    • Full Room Booking integration
    • Page, blog, menu, contact… modules are provided with the use of components to avoid boilerplate code.
    • Powerful media system, also support Amazon S3, DigitalOcean Spaces
    • SEO & sitemap support: access sitemap.xml to see more.
    • Google Analytics: display analytics data in admin panel.
    • Translation tool: easy to translate front theme and admin panel to your language.
    • Beautiful theme is ready to use.
    • Powerful Permission System: Manage user, team, role by permissions. Easy to manage user by permissions.
    • Admin template comes with color schemes to match your taste.
    • Fully Responsive: Compatible with all screen resolutions.
    • Coding Standard: All code follow coding standards PSR-2 and best practices.

    Server Requirements

    • Apache, nginx, or another compatible web server.
    • PHP >= 7.3 >> Higher
    • MySQL Database server
    • PDO PHP Extension
    • OpenSSL PHP Extension
    • Mbstring PHP Extension
    • Exif PHP Extension
    • Fileinfo Extension
    • XML PHP Extension
    • Ctype PHP Extension
    • JSON PHP Extension
    • Tokenizer PHP Extension
    • Module Re_write server
    • PHP_CURL Module Enable

    Installation

    Above all, to run this project you must have installed a virtual server i.e XAMPP on your PC. Complete Online Hotel Booking System in PHP and MySQL with source code is free to download

    Follow the following steps after Starting Apache and MySQL in XAMPP:

    1st Step: Firstly, Extract the file
    2nd Step: After that, Copy the main project folder
    3rd Step: So, you need to Paste in xampp/htdocs/

    Further, Now Connecting Database

    4th Step: So, for now, Open a browser and go to URL “http://localhost/phpmyadmin/”
    5th Step: After that, Click on the databases tab
    6th Step: So, Create a database naming “resort” and then click on the import tab
    7th Step: Certainly, Click on browse file and select “database.sql” file which is inside the root folder
    8th Step: Meanwhile, click on Go button.

    After Creating Database,

    9th Step: Moreover, Open a browser and go to URL “http://localhost/”

    Screenshots

    online hotel booking system free download

    online hotel booking system

    online hotel booking system

    Login Access Information

    Username: botble
    Password: 159357

    Test accounts for payment

    PayPal: test@botble.com – 12345678
    Credit Card for Stripe: 4242 4242 4242 4242 – Anything in the CVV and expiration date
    Credit Card for SSLCommerz: 4111111111111111, Exp: 12/25, CVV: 111

    Demonstration

    I hope this Complete Online Hotel Booking System using PHP MySQL will help you with what you are looking for and hope that you will learn something with this project that is useful for your future projects.

    Free Download Complete Online Hotel Booking System

    Источник

Оцените статью