Hotel Booking System Project Using PHP(PDO) and MYSQL

Rashmi Mishra
0

 

Project Report


Hotel Booking System

Table of Contents

1.     Project Overview

2.     Objectives

3.     Technologies Used

4.     Database Design

5.     Implementation Details

o    1. Setting Up the Environment

o    2. Application Structure

o    3. Database Connection

o    4. User Authentication

o    5. Room Management

o    6. Booking Management

o    7. User Interface Design

o    8. Security Considerations

6.     Testing

o    1. Testing Strategies

o    2. Test Cases

o    3. User Acceptance Testing

7.     Deployment

8.     Project Management

o    1. Agile Methodology

o    2. Timeline

9.     Conclusion

10. Future Enhancements

11. Appendix

o    1. Code Snippets

o    2. User Guides

o    3. References


1. Project Overview

The Hotel Booking System is a web-based application designed to streamline the process of booking hotel rooms for users. It allows users to search for available rooms, view details, and make reservations efficiently. The system also provides administrative functionalities to manage room availability, user accounts, and bookings.

The project was developed using PHP, with PDO as the data access layer for secure database interactions. The front end is built using HTML, CSS, and Bootstrap for responsive design, ensuring a seamless user experience on various devices.

Project Goals

  • Provide an intuitive interface for users to browse and book hotel rooms.
  • Ensure secure user authentication and data management.
  • Allow administrators to manage room information and user bookings.

2. Objectives

The main objectives of this project include:

1.     User Registration and Login: Implement secure user registration and login functionality.

2.     Room Management: Enable administrators to add, edit, and remove rooms from the system.

3.     Booking System: Allow users to book rooms based on availability, with options for check-in and check-out dates.

4.     User Dashboard: Provide a dashboard for users to view their bookings and manage their profiles.

5.     Admin Dashboard: Create an admin interface to manage users and bookings effectively.


3. Technologies Used

The development of the Hotel Booking System involved the following technologies:

  • Frontend Technologies:
    • HTML: For structuring the web pages.
    • CSS: For styling the web pages.
    • Bootstrap: A responsive front-end framework to design the user interface.
  • Backend Technologies:
    • PHP: The server-side scripting language used for application logic.
    • PDO (PHP Data Objects): A database access layer that provides a uniform method of access to multiple databases.
  • Database:
    • MySQL: The database management system used to store user, room, and booking information.
  • Development Tools:
    • XAMPP/WAMP: For setting up a local server environment for development.
    • Visual Studio Code: As the code editor for development.

4. Database Design

The database for the Hotel Booking System consists of the following tables:

1.     Users Table

o    Schema:

CREATE TABLE users (

    id INT AUTO_INCREMENT PRIMARY KEY,

    name VARCHAR(100) NOT NULL,

    email VARCHAR(100) NOT NULL UNIQUE,

    password VARCHAR(255) NOT NULL,

    role ENUM('user', 'admin') DEFAULT 'user',

    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

o    Description: Stores user information, including their role (admin or user).

2.     Rooms Table

o    Schema:

CREATE TABLE rooms (

    id INT AUTO_INCREMENT PRIMARY KEY,

    type VARCHAR(100) NOT NULL,

    description TEXT,

    status ENUM('Available', 'Booked', 'Under Maintenance') DEFAULT 'Available',

    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

o    Description: Contains details about hotel rooms, including their current status.

3.     Bookings Table

o    Schema:

CREATE TABLE bookings_tbl (

    id INT AUTO_INCREMENT PRIMARY KEY,

    user_id INT NOT NULL,

    room_id INT NOT NULL,

    check_in DATE NOT NULL,

    check_out DATE NOT NULL,

    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    FOREIGN KEY (user_id) REFERENCES users(id),

    FOREIGN KEY (room_id) REFERENCES rooms(id)

);

o    Description: Records the bookings made by users, linking them to specific rooms.

Entity-Relationship Diagram (ERD)

An Entity-Relationship Diagram (ERD) visually represents the entities in your Hotel Booking System and the relationships between them. Below is a textual description of the ERD, including the key entities, their attributes, and relationships. You can create the ERD using diagramming tools like Lucidchart, Draw.io, or any ERD software.

Entities and Attributes

1.     User

o    Attributes:

§  id (Primary Key)

§  name

§  email (Unique)

§  password

§  role (e.g., user, admin)

§  created_at

§  updated_at

2.     Room

o    Attributes:

§  id (Primary Key)

§  room_number

§  room_type (e.g., single, double, suite)

§  price

§  availability_status (e.g., available, booked)

§  created_at

§  updated_at

3.     Booking

o    Attributes:

§  id (Primary Key)

§  user_id (Foreign Key referencing User)

§  room_id (Foreign Key referencing Room)

§  check_in (Date)

§  check_out (Date)

§  created_at

§  updated_at

Relationships

  • User to Booking:
    • A user can make multiple bookings.
    • Relationship: One-to-Many (1 User → 0..* Bookings)
  • Room to Booking:
    • A room can be booked multiple times but not simultaneously.
    • Relationship: One-to-Many (1 Room → 0..* Bookings)

ERD Diagram Representation

Here’s a simple text representation of how the ERD would look:

+-----------------+        +-----------------+        +-----------------+

|      User       |        |      Room       |        |     Booking      |

+-----------------+        +-----------------+        +-----------------+

| - id (PK)       |<-----0..*| - id (PK)      |       | - id (PK)       |

| - name          |         | - room_number   |       | - user_id (FK)  |

| - email         |         | - room_type     |       | - room_id (FK)  |

| - password      |         | - price         |       | - check_in       |

| - role          |         | - availability   |       | - check_out      |

| - created_at    |         | - created_at    |       | - created_at     |

| - updated_at    |         | - updated_at    |       | - updated_at     |

+-----------------+         +-----------------+       +-----------------+

Additional Notes

  • Foreign Keys:
    • The user_id in the Booking table refers to the id of the User.
    • The room_id in the Booking table refers to the id of the Room.

Creating the ERD

To create a visual ERD:

1.     Use a diagramming tool to draw the entities as boxes.

2.     Add attributes inside each entity box.

3.     Draw lines to represent relationships between entities, labeling them appropriately.

4.     Indicate cardinality (1 to many) next to the relationship lines.

This ERD provides a foundational understanding of how your Hotel Booking System's database will be structured and how the entities interact with one another.

Data Flow Diagram (DFD)

A Data Flow Diagram (DFD) visually represents how data flows through the system, illustrating the processes, data stores, and data sources involved in the Hotel Booking System. Below is a textual description of a Level 1 DFD, which includes the key processes, data flows, external entities, and data stores. You can create the DFD using diagramming tools like Lucidchart, Draw.io, or any DFD software.

Components of the DFD

1.     External Entities

o    User: Individuals who book rooms, manage their accounts, and make payments.

o    Admin: Users responsible for managing rooms, bookings, and users.

2.     Processes

o    Process 1: User Registration and Login

§  Users can register and log in to their accounts.

o    Process 2: Room Management

§  Admin manages room details (add, edit, delete).

o    Process 3: Booking Management

§  Users can view available rooms and make bookings.

o    Process 4: Payment Processing

§  Users make payments for their bookings.

o    Process 5: Booking Confirmation

§  System confirms the booking and sends a confirmation to the user.

3.     Data Stores

o    Data Store 1: User Data (Stores user information)

o    Data Store 2: Room Data (Stores room details)

o    Data Store 3: Booking Data (Stores booking information)

o    Data Store 4: Payment Data (Stores payment information)

DFD Level 1 Representation

Below is a simple text representation of how the DFD Level 1 would look:

+------------------+     +--------------------+     +--------------------+

|    External       |     |                    |     |                    |

|    Entity         |     |     Process        |     |   Data Store       |

|                   |     |                    |     |                    |

|   User            |<--->| 1. User            |     |                    |

|                   |     |    Registration &   |<--->| User Data         |

+------------------+     |    Login           |     |                    |

                         |                    |     +--------------------+

                         |                    |

                         |                    |

                         |                    |<------------------+

                         |     +--------------------+             |

                         |     |     Process        |             |

                         |     |                    |             |

                         |<--->| 2. Room Management |<------------+

                         |     |                    |

                         |     +--------------------+

                         |                    |

                         |                    |    

                         |                    |    

                         |                    |    

                         |                    |    

                         |     +--------------------+    

                         |     |     Process        |

                         |     |                    |

                         |<--->| 3. Booking         |<-->[Booking Data]

                         |     |    Management       |

                         |     +--------------------+

                         |                    |

                         |                    |

                         |                    |

                         |     +--------------------+

                         |     |     Process        |

                         |     |                    |

                         |<--->| 4. Payment         |<-->[Payment Data]

                         |     |    Processing       |

                         |     +--------------------+

                         |                    |

                         |                    |

                         |     +--------------------+

                         |     |     Process        |

                         |     |                    |

                         |<--->| 5. Booking         |

                         |     |    Confirmation     |

                         |     +--------------------+

                         |

                         |

                    +-------------------+

                    |                   |

                    |    Admin          |

                    |                   |

                    +-------------------+

Data Flows Description

  • User Registration and Login:
    • Users send registration and login data to the system.
    • The system retrieves and stores user data in the User Data store.
  • Room Management:
    • Admin manages rooms by sending room details to the system.
    • The system retrieves and stores room data in the Room Data store.
  • Booking Management:
    • Users send booking requests to the system.
    • The system checks available rooms and updates the Booking Data store.
  • Payment Processing:
    • Users send payment information to the system.
    • The system processes payments and stores the data in the Payment Data store.
  • Booking Confirmation:
    • The system sends booking confirmation to users after successful bookings.

Creating the DFD

To create a visual DFD:

1.     Use a diagramming tool to draw the external entities as rectangles.

2.     Represent processes as circles or rounded rectangles.

3.     Use arrows to represent data flows between entities, processes, and data stores.

4.     Label all elements clearly, indicating the direction of data flow.


5. Implementation Details

5.1 Setting Up the Environment

  • Installation of XAMPP/WAMP:

1.     Download and install XAMPP or WAMP from their official websites.

2.     Start the Apache and MySQL services from the control panel.

  • Database Creation:

1.     Access phpMyAdmin via http://localhost/phpmyadmin.

2.     Create a new database named hotel_booking_system.

3.     Execute the SQL scripts to create the necessary tables.

5.2 Application Structure

The project structure is organized as follows:

/hotel-booking-system

    /config

        db.php

    /controllers

        UserController.php

        RoomController.php

        BookingController.php

 

    /models

        Booking.php

        Room.php

        User.php

    /views

         /user

Add_room.php

Admin_dashboard.php

Available_rooms.php

Book_rooms.php

Book.php

Booking_admi.php

Booking.php

Edit_user.php

Login.php

Logout.php

Manage-rooms.php

Profile.php

Register.php

User_dashboard.php

User_management.php

    /public

        index.php

    /assets

        /css

        /js

Index.php

.htaccess

Readme.md

5.3 Database Connection

The database connection is established in db.php using the PDO method, which allows for prepared statements to mitigate SQL injection risks.

<?php

$host = 'localhost';

$dbname = 'hotel_booking_system';

$username = 'root';

$password = '';

try {

    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);

    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

} catch (PDOException $e) {

    die("Database connection failed: " . $e->getMessage());

}

?>

5.4 User Authentication

  • User Registration:
    • Users can register by providing their name, email, and password. Passwords are hashed for security.

public function register($name, $email, $password) {

    $hashedPassword = password_hash($password, PASSWORD_DEFAULT);

    $stmt = $this->db->prepare("INSERT INTO users (name, email, password) VALUES (:name, :email, :password)");

    $stmt->bindParam(':name', $name);

    $stmt->bindParam(':email', $email);

    $stmt->bindParam(':password', $hashedPassword);

    return $stmt->execute();

}

  • User Login:
    • Users log in using their email and password. The entered password is verified against the hashed password stored in the database.

public function login($email, $password) {

    $stmt = $this->db->prepare("SELECT * FROM users WHERE email = :email");

    $stmt->bindParam(':email', $email);

    $stmt->execute();

    $user = $stmt->fetch(PDO::FETCH_ASSOC);

   

    if ($user && password_verify($password, $user['password'])) {

        $_SESSION['user_id'] = $user['id'];

        return true;

    }

    return false;

}

5.5 Room Management

  • Adding a Room:
    • Admins can add new rooms to the database, specifying type, description, and initial status.

public function addRoom($type, $description, $status) {

    $stmt = $this->db->prepare("INSERT INTO rooms (type, description, status) VALUES (:type, :description, :status)");

    $stmt->bindParam(':type', $type);

    $stmt->bindParam(':description', $description);

    $stmt->bindParam(':status', $status);

    return $stmt->execute();

}

  • Editing Room Details:
    • Admins can edit existing room details as necessary.

5.6 Booking Management

  • Creating a Booking:
    • Users can book rooms by selecting available rooms and specifying check-in and check-out dates.

public function createBooking($userId, $roomId, $checkIn, $checkOut) {

    $stmt = $this->db->prepare("INSERT INTO bookings (user_id, room_id, check_in, check_out) VALUES (:user_id, :room_id, :check_in, :check_out)");

    $stmt->bindParam(':user_id', $userId);

    $stmt->bindParam(':room_id', $roomId);

    $stmt->bindParam(':check_in', $checkIn);

    $stmt->bindParam(':check_out', $checkOut);

    return $stmt->execute();

}

5.7 User Interface Design

  • Homepage: Users are greeted with an intuitive homepage displaying room options and a search bar.
  • Room Listing: Users can view all available rooms with details and booking options.
  • Dashboard: Both users and admins have separate dashboards to manage their activities effectively.

5.8 Security Considerations

  • Input Validation: All user inputs are validated to prevent malicious data entries.
  • Password Hashing: Passwords are stored as hashed values using the password_hash() function to enhance security.

6. Testing

6.1 Testing Strategies

The testing strategy employed for the Hotel Booking System includes:

  • Unit Testing: Individual components such as user registration, login, room management, and booking functionality are tested for expected behavior.
  • Integration Testing: Ensures that different modules interact correctly, such as user authentication and booking processes.
  • User Acceptance Testing (UAT): Engages potential users to validate the system meets their requirements.

6.2 Test Cases

Some sample test cases include:

Test Case ID

Description

Expected Result

Status

TC-001

User registration with valid data

User is registered successfully

Pass

TC-002

User login with valid credentials

User is logged in

Pass

TC-003

Book a room with valid details

Booking is created

Pass

TC-004

Admin adds a new room

Room is added successfully

Pass

TC-005

User attempts to book an unavailable room

Booking fails with error message

Pass

6.3 User Acceptance Testing

Feedback from users during the UAT phase indicated a need for improved UI design and clearer navigation. Changes were made based on this feedback to enhance user experience.


7. Deployment

The deployment of the Hotel Booking System involves:

1.     Selecting a Hosting Provider: Choosing a suitable hosting environment that supports PHP and MySQL.

2.     Database Migration: Importing the database schema and data to the live server using tools like phpMyAdmin.

3.     Application Configuration: Adjusting configurations in db.php for the production environment.

4.     Final Testing: Performing final tests in the production environment to ensure everything is functioning as expected.


8. Project Management

8.1 Agile Methodology

The project followed an Agile methodology, which allowed for iterative development and regular feedback loops. Daily stand-ups and bi-weekly sprints facilitated collaboration among team members.

8.2 Timeline

The following timeline outlines the major phases of the project:

Phase

Duration

Requirement Gathering

2 weeks

Design

1 week

Development

4 weeks

Testing

2 weeks

Deployment

1 week

Total Duration

10 weeks


9. Conclusion

The Hotel Booking System successfully provides a comprehensive solution for hotel room booking and management. The application meets user requirements and is built on a robust technical foundation, ensuring scalability and maintainability.


10. Future Enhancements

  • Mobile App Development: Expanding the system into a mobile application for easier access.
  • Payment Integration: Implementing online payment gateways to facilitate secure transactions.
  • Advanced Analytics: Adding analytics for administrators to better understand booking trends and user behavior.

11. Appendix

11.1 Code Snippets

(Include relevant code snippets that highlight key functionalities.)

11.2 User Guides

  • User Manual: A detailed guide for users on how to navigate and use the system.
  • Admin Manual: Instructions for administrators on managing the application.

11.3 References


This structure will help you develop a detailed 20-page project report for your Hotel Booking System. You can expand each section further by adding diagrams, detailed code comments, user interface screenshots, and any other relevant materials to achieve the desired length and depth.



ScreenShots


 



2

3


4

5


6

7


8



9


10




11








TO DOWNLOAD SOURCE CODE INBOX HERE




















Post a Comment

0Comments

Post a Comment (0)