0% found this document useful (0 votes)
32 views39 pages

Anilrp

The document is a mini project report on 'Hotel Booking Management' submitted by Anil S D for the Bachelor of Engineering in Computer Science and Engineering. It outlines the development of a web-based application designed to automate hotel room bookings, manage reservations, and handle customer data, utilizing technologies such as HTML, CSS, JavaScript, and Python with MySQL. The project aims to enhance operational efficiency and customer satisfaction in the hospitality industry by providing a user-friendly interface and robust administrative tools.

Uploaded by

anisdsmh92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views39 pages

Anilrp

The document is a mini project report on 'Hotel Booking Management' submitted by Anil S D for the Bachelor of Engineering in Computer Science and Engineering. It outlines the development of a web-based application designed to automate hotel room bookings, manage reservations, and handle customer data, utilizing technologies such as HTML, CSS, JavaScript, and Python with MySQL. The project aims to enhance operational efficiency and customer satisfaction in the hospitality industry by providing a user-friendly interface and robust administrative tools.

Uploaded by

anisdsmh92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

BELGAUM

A MINI PROJECT REPORT ON


“HOTEL BOOKING MANAGEMENT”
Submitted in partial fulfilment of the requirements
For the award of the 4rd Sem of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
SUBMITTED BY:
ANIL S D
[1VE23CS012]
Under the guidance of
Mrs. Ranjana Thakuria
Asst. Prof, Dept. of CSE

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING
SRI VENKATESHWARA COLLEGE OF ENGINEERING
BANGALORE-562157
2024-25

1
STUDENT DECLARATION

I, ANIL S D (1VE23CS0), hereby declare that the mini project work entitled “HOTEL
BOOKING MANAGEMENT” submitted in partial fulfilment of the requirements for the IV
semester Bachelor of Engineering in Computer Science and Engineering under Visvesvaraya
Technological University, Belgaum, is the result of my own work carried out during the
academic year 2024-25.

I further declare that this project has not been submitted to any other university or institution
for the award of any degree or diploma. All the information provided in this report is genuine
to the best of my knowledge and belief.

__________________
Signature of the Student
ANIL S D [1VE23CS012]

2
SRI VENKATESHWARA COLLEGE OF ENGINEERING
(Affiliated by AICTE and approved by V.T.U)

CERTIFICATE
This is to certify that mini project work entitled “HOTEL BOOKING MANAGEMENT”
submitted in partial fulfilment of the requirement for IV semester bachelor of engineering in
computer science and engineering prescribed by the Visvesvaraya Technological University,
Belgaum is a result of the Bonafide work carried out by ANIL S D [1VE23CS012], during
the academic year 2024-25. It is certified that all corrections/suggestions indicated for internal
assessment have been incorporated in the report deposited in the departmental library. The
project report has been approved as it satisfies the academic requirements of project work
prescribed for the said Degree.

Signature of Guide\Course Teacher


Mrs. RANJANA THAKURIA
Asst. Prof, Dept. of CSE

3
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany the successful completion of any task would be
incomplete without complementing those who made it possible, whose guidance and
encouragement made our efforts successful.

Our sincere thanks to highly esteemed institution SRI VENKATESHWARA COLLEGE OF


ENGINEERING for grooming up us in to be software engineer.

We express our sincere gratitude to Dr. B M SATISH, Principal, SVCE, Bengaluru for
providing the required facility.

We extremely thankful to Dr. MUKESH KUMAR SINGH, HOD of CSE, SVCE for
providing support and encouragement.

We are grateful to Mrs. RANJANA THAKURIA, Asst. Professor, Dept. of CSE, SVCE who
helped us to complete this project successfully by providing guidance, encouragement and
valuable suggestion during entire period of the project. We thank all my computer science staff
and others who helped directly or indirectly to meet my project work with grand success.

Finally, we are grateful to my parents and friends for their individual support guidance and
encouragement.

ANIL S D [1VE23CS012]

4
CONTENTS:

SL NO CHAPTER TITLE PAGE NO


01 Abstract 6
02 Introduction 7-8
03 Requirements 9-10
04 Implementation and results 11-14
05 Conclusion 15
06 Annexure-1: Coding 16-38
07 References 39

5
1. ABSTRACT

The Hotel Booking Management System is a web-based software application developed to


automate and streamline the process of booking hotel rooms, managing reservations, and
handling customer data. In today’s fast-paced digital environment, manual reservation methods
are inefficient and error-prone, often leading to overbooking, data loss, and poor customer
satisfaction. This system aims to overcome these limitations by offering a user-friendly, secure,
and scalable solution that can cater to the needs of both hotel staff and customers.
The system is designed with two main user roles: customers and administrators. Customers
can browse room types, check availability, make reservations, and manage their bookings. The
admin panel allows hotel staff to add or remove rooms, view booking details, monitor room
occupancy, and generate reports for operational decision-making. The application uses a
relational database to store information about rooms, users, and bookings, ensuring data
integrity and consistency.
Developed using modern web technologies—such as HTML, CSS, JavaScript for the frontend
and Python (Flask) with MySQL for the backend—the system supports responsive design to
ensure accessibility on both desktop and mobile platforms. Security measures such as hashed
passwords and session-based authentication have been implemented to safeguard user
information.

6
2. INTRODUCTION

The hospitality industry has undergone significant transformation with the integration of
digital technologies aimed at improving customer service and operational efficiency. One of
the key areas where technology has made a profound impact is hotel reservation systems.
Traditionally, booking hotel rooms involved manual entries in registers, phone calls, or third-
party travel agents, which were time-consuming and prone to human errors such as double
bookings or lost reservations. In response to these limitations, the Hotel Booking
Management System has been developed to provide a streamlined, automated, and user-
friendly platform for both customers and hotel administrators.

This project focuses on creating a web-based system that facilitates real-time room booking,
availability checking, customer data management, and administrative controls. The system is
designed to reduce dependency on manual processes, increase accuracy, and provide
customers with the convenience of booking rooms from anywhere at any time.

2.1 Background

Traditional With the rapid advancement of information technology, various industries have
embraced automation to improve efficiency, accuracy, and customer satisfaction. The
hospitality industry, particularly hotel management, has significantly benefited from these
technological innovations. Traditionally, hotel bookings were handled manually through
telephone calls, walk-ins, or intermediaries, requiring staff to maintain paper-based records of
room availability, customer details, and payment transactions. This manual approach often
resulted in overbooking, missed reservations, and time-consuming administrative processes.

The increasing use of the internet and smartphones has led to a shift in customer behavior,
with most travelers now preferring to make hotel reservations online. This shift has created
the need for a robust, dynamic, and interactive hotel booking system that can provide real-
time updates, secure transactions, and user-friendly interfaces. The Hotel Booking
Management System was conceptualized to meet this demand by providing an integrated
platform where customers can view room availability, make reservations, and manage
bookings with ease, while hotel administrators can efficiently monitor and manage the entire
booking process.

7
2.2 Project Scope
2.3
• Develop a web-based Hotel Booking Management System for automating room

reservations and hotel administration tasks.

• Allow customers to:

o Register and log in securely.

o Search for available rooms by date and type.

o Make, view, modify, or cancel bookings.

o Receive booking confirmation and details.

• Enable administrators/hotel staff to:

o Log in through a secure admin panel.

o Add, edit, or remove room listings.

o View and manage customer bookings.

o Access booking history and generate basic reports.

• Implement a database to store information on users, rooms, and bookings securely and

efficiently.

• Design a responsive user interface that works on both desktop and mobile devices.

• Ensure data security through authentication, session management, and password

protection.

• Limit the initial scope to core functionalities for small-to-mid-sized hotels.

• Allow for future scalability, including the potential integration of payment gateways,

third-party APIs, and advanced analytics.

8
3 REQUIREMENTS

Functional Requirements

• User registration and login

• Room search and availability checking

• Room booking and cancellation

• Payment processing

• Admin login for room and booking management

• Viewing and updating customer data

3.2 Non-Functional Requirements

• User-friendly interface

• Secure authentication and data handling

• Responsive design (for mobile and desktop)

• Scalability to support more users/rooms

3.3 Software Requirements

• Frontend: HTML, CSS, JavaScript

• Backend: Python (Flask/Django) or PHP/Node.js

• Database: MySQL or SQLite

• Server: Localhost or cloud (e.g., XAMPP, Heroku)

3.4 Hardware Requirements

• Computer with minimum 4GB RAM

• Internet connection (for web-based deployment)

9
Frontend Technologies:

• HTML5 – for structuring web pages

• CSS3 – for styling and layout

• Bootstrap – for responsive design

Backend Technologies:

• Python with Flask / Django (or PHP / Node.js based on preference) – for server-side
logic

• MySQL / SQLite – for database management

Tools and Platforms:

• Visual Studio Code / PyCharm – for code development

• XAMPP / WAMP (if using PHP and MySQL)

• Postman – for API testing (optional)

• Git – for version control

• Web browser (Chrome, Firefox) – for testing UI

10
1. IMPLEMENTATION AND RESULTS

The project was implemented using the Python Flask framework with a MySQL database.
The following modules were created:

• User Interface: Designed using HTML, CSS, and Bootstrap for responsive
layout. It includes pages for login, registration, room listings, and bookings.

• Database Design: Tables include users, rooms, bookings, and payments.

• Booking Module: Allows users to check room availability by date and type,
and book if available.

• Admin Panel: Enables staff to add or remove rooms, manage bookings, and
view reports.

• Security Features: Password hashing and session management were o ensure


data privacy.

The Hotel Booking Management System successfully met all functional requirements:

• Users were able to create accounts, log in, search for available rooms, and make
bookings.

• The system prevented double booking by locking unavailable rooms.

• Admins could monitor room availability and manage user bookings efficiently.

• Data was stored and retrieved reliably using the MySQL database.

• The web interface worked on desktops and mobile devices.

Sample screenshots of modules:

• Room Search Page

• Booking Confirmation Page

• Admin Dashboard

11
OUTPUT:

12
13
2. CONCLUSION

• The Hotel Booking Management System successfully addresses the common


challenges faced by hotels in managing room reservations and customer data. By
automating the booking process, the system reduces manual errors, prevents double
bookings, and enhances the overall efficiency of hotel operations. It offers a user-
friendly interface for customers to easily search, book, and manage reservations,
while also providing hotel staff with robust tools to manage room availability and
bookings from an administrative panel.

• Through this project, key concepts of web development, database management, and
system design have been applied to create a practical, real-world application. The
modular structure and scalable design ensure that the system can be enhanced in the
future with features like online payments, notifications, and advanced analytics.
Overall, the project demonstrates how technology can improve service delivery in the
hospitality industry and provides a strong foundation for more advanced hotel
management solutions.

14
3. ANNEXURE:1 CODING
Base.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}Hotel Booking{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.0.0/css/all.min.css" />
{% block extra_css %}{% endblock %}
</head>
<body>
<nav class="main-nav">
<div class="nav-container">
<a href="{{ url_for('index') }}" class="nav-logo"> <i class="fas fa-hotel"></i> Hotel
Booking </a>
<div class="nav-links">
<a href="{{ nav_links.home.url }}">
<i class="fas {{ nav_links.home.icon }}"></i> {{ nav_links.home.text }}
</a>
<a href="{{ nav_links.add_hotel.url }}">
<i class="fas {{ nav_links.add_hotel.icon }}"></i> {{ nav_links.add_hotel.text }}
</a>
{% if session.get('user_id') %}
<a href="{{ nav_links.my_bookings.url }}">
<i class="fas {{ nav_links.my_bookings.icon }}"></i> {{ nav_links.my_bookings.text
}}
</a>
<a href="{{ nav_links.profile.url }}" class="profile-link">
<i class="fas {{ nav_links.profile.icon }}"></i> {{ nav_links.profile.text }}
</a>
<a href="{{ nav_links.logout.url }}" class="logout-link">
<i class="fas {{ nav_links.logout.icon }}"></i> {{ nav_links.logout.text }}
</a>
{% else %}
<a href="{{ nav_links.login.url }}" class="login-link">
<i class="fas {{ nav_links.login.icon }}"></i> {{ nav_links.login.text }}
</a>
<a href="{{ nav_links.signup.url }}" class="signup-link">

15
<i class="fas {{ nav_links.signup.icon }}"></i> {{ nav_links.signup.text }}
</a>
{% endif %}
</div>
</div>
</nav>

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}


<div class="flash-messages">
{% for category, message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %}
</div>
{% endif %} {% endwith %}

<main>{% block content %}{% endblock %}</main>

<footer class="main-footer">
<div class="footer-content">
<p>&copy; 2024 Hotel Booking. All rights reserved.</p>
</div>
</footer>

{% block extra_js %}{% endblock %}


</body>
</html>

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hotel Booking</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.0.0/css/all.min.css" />
</head>
<body>
<nav class="main-nav">
<div class="nav-container">
<a href="{{ url_for('index') }}" class="nav-logo"> <i class="fas fa-hotel"></i> Hotel
Booking </a>
16
<div class="nav-links">
<a href="{{ url_for('index') }}">Home</a>
<a href="{{ url_for('add_hotel') }}">Add Hotel</a>
{% if session.get('user_id') %}
<a href="{{ url_for('my_bookings') }}">My Bookings</a>
<a href="{{ url_for('profile') }}" class="profile-link">
<i class="fas fa-user-circle"></i> Profile
</a>
<a href="{{ url_for('logout') }}" class="logout-link">
<i class="fas fa-sign-out-alt"></i> Logout
</a>
{% else %}
<a href="{{ url_for('login') }}" class="login-link"> <i class="fas fa-sign-in-alt"></i>
Login </a>
<a href="{{ url_for('signup') }}" class="signup-link"> <i class="fas fa-user-plus"></i>
Sign Up </a>
{% endif %}
</div>
</div>
</nav>

<header class="hotel-header">
<div class="header-content">
<h1>Welcome to Hotel Booking</h1>
<p>Find your perfect stay with us</p>
</div>
</header>

<main>
<div class="hotel-list">
{% for hotel in hotels %}
<div class="hotel">
<div class="hotel-image">
<img
src="{{ hotel.image_url or 'https://via.placeholder.com/400x250' }}"
alt="{{ hotel.name }}"
/>
<div class="image-overlay">
<span class="hotel-rating">
<i class="fas fa-star"></i>
{% if hotel.reviews %} {{ (hotel.reviews|sum(attribute='rating') /
hotel.reviews|length)|round(1) }} {% else %} New {% endif %}
</span>
</div>

17
</div>
<div class="hotel-info">
<h2>{{ hotel.name }}</h2>
<p class="location"><i class="fas fa-map-marker-alt"></i> {{ hotel.location }}</p>
<p class="description">{{ hotel.description }}</p>
<a href="{{ url_for('hotel_details', hotel_id=hotel.id) }}" class="book-now-link">
<i class="fas fa-info-circle"></i> View Details
</a>
</div>
</div>
{% endfor %}
</div>
</main>

<footer class="main-footer">
<div class="footer-content">
<p>&copy; 2024 Hotel Booking. All rights reserved.</p>
</div>
</footer>
</body>
</html>

login.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login - Hotel Booking</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.0.0/css/all.min.css" />
</head>
<body>
<nav class="main-nav">
<div class="nav-container">
<a href="{{ url_for('index') }}" class="nav-logo"> <i class="fas fa-hotel"></i> Hotel
Booking </a>
<div class="nav-links">
<a href="{{ url_for('index') }}">Home</a>
<a href="{{ url_for('signup') }}">Sign Up</a>
</div>
</div>
18
</nav>

<main class="auth-container">
<div class="auth-card">
<h1><i class="fas fa-sign-in-alt"></i> Login</h1>

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}


{% for category,
message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %} {% endif %} {% endwith %}

<form method="POST" action="{{ url_for('login') }}" class="auth-form">


<div class="form-group">
<label for="email">Email</label>
<div class="input-with-icon">
<i class="fas fa-envelope"></i>
<input type="email" id="email" name="email" required />
</div>
</div>

<div class="form-group">
<label for="password">Password</label>
<div class="input-with-icon">
<i class="fas fa-lock"></i>
<input type="password" id="password" name="password" required />
</div>
</div>

<button type="submit" class="submit-button"><i class="fas fa-sign-in-alt"></i>


Login</button>
</form>

<div class="auth-links">
<p>Don't have an account? <a href="{{ url_for('signup') }}">Sign Up</a></p>
</div>
</div>
</main>

<footer class="main-footer">
<div class="footer-content">
<p>&copy; 2024 Hotel Booking. All rights reserved.</p>
</div>
</footer>

19
</body>
</html>

login.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login - Hotel Booking</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.0.0/css/all.min.css" />
</head>
<body>
<nav class="main-nav">
<div class="nav-container">
<a href="{{ url_for('index') }}" class="nav-logo"> <i class="fas fa-hotel"></i> Hotel
Booking </a>
<div class="nav-links">
<a href="{{ url_for('index') }}">Home</a>
<a href="{{ url_for('signup') }}">Sign Up</a>
</div>
</div>
</nav>

<main class="auth-container">
<div class="auth-card">
<h1><i class="fas fa-sign-in-alt"></i> Login</h1>

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}


{% for category,
message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %} {% endif %} {% endwith %}

<form method="POST" action="{{ url_for('login') }}" class="auth-form">


<div class="form-group">
<label for="email">Email</label>
<div class="input-with-icon">
<i class="fas fa-envelope"></i>
<input type="email" id="email" name="email" required />
</div>
20
</div>

<div class="form-group">
<label for="password">Password</label>
<div class="input-with-icon">
<i class="fas fa-lock"></i>
<input type="password" id="password" name="password" required />
</div>
</div>

<button type="submit" class="submit-button"><i class="fas fa-sign-in-alt"></i>


Login</button>
</form>

<div class="auth-links">
<p>Don't have an account? <a href="{{ url_for('signup') }}">Sign Up</a></p>
</div>
</div>
</main>

<footer class="main-footer">
<div class="footer-content">
<p>&copy; 2024 Hotel Booking. All rights reserved.</p>
</div>
</footer>
</body>
</html>

profile.html

{% extends "base.html" %} {% block title %}My Profile - Hotel Booking{% endblock %} {%


block content %}
<div class="profile-container">
<div class="profile-header">
<div class="profile-avatar">
<i class="fas fa-user-circle"></i>
</div>
<div class="profile-info">
<h1>{{ user.username }}</h1>
<p class="profile-email"><i class="fas fa-envelope"></i> {{ user.email }}</p>
<p class="profile-join-date">
<i class="fas fa-calendar-alt"></i> Member since {{ user.created_at.strftime('%B %Y') }}
</p>
</div>
21
</div>

<div class="profile-stats">
<div class="stat-card">
<i class="fas fa-hotel"></i>
<div class="stat-info">
<h3>Total Bookings</h3>
<p>{{ bookings|length }}</p>
</div>
</div>
<div class="stat-card">
<i class="fas fa-star"></i>
<div class="stat-info">
<h3>Reviews Given</h3>
<p>{{ reviews|length }}</p>
</div>
</div>
</div>

<div class="profile-sections">
<section class="recent-bookings">
<h2><i class="fas fa-history"></i> Recent Bookings</h2>
{% if bookings %}
<div class="bookings-list">
{% for booking in bookings[:3] %}
<div class="booking-card">
<div class="booking-header">
<h3>{{ booking.room.hotel.name }}</h3>
<span class="booking-status {{ booking.status.lower() }}">{{ booking.status
}}</span>
</div>
<div class="booking-details">
<div class="booking-dates">
<div class="date-group">
<i class="fas fa-calendar-check"></i>
<div>
<label>Check-in</label>
<p>{{ booking.checkin.strftime('%B %d, %Y') }}</p>
</div>
</div>
<div class="date-group">
<i class="fas fa-calendar-times"></i>
<div>
<label>Check-out</label>

22
<p>{{ booking.checkout.strftime('%B %d, %Y') }}</p>
</div>
</div>
</div>
<div class="booking-info">
<div class="info-group">
<i class="fas fa-bed"></i>
<div>
<label>Room Type</label>
<p>{{ booking.room.type }}</p>
</div>
</div>
<div class="info-group">
<i class="fas fa-dollar-sign"></i>
<div>
<label>Total Price</label>
<p>${{ "%.2f"|format(booking.total_price) }}</p>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% if bookings|length > 3 %}
<div class="view-all">
<a href="{{ url_for('my_bookings') }}" class="view-all-btn">View All Bookings</a>
</div>
{% endif %} {% else %}
<p class="no-bookings">No bookings found.</p>
{% endif %}
</section>

<section class="recent-reviews">
<h2><i class="fas fa-star"></i> Recent Reviews</h2>
{% if reviews %}
<div class="reviews-list">
{% for review in reviews[:3] %}
<div class="review-card">
<div class="review-header">
<h3>{{ review.hotel.name }}</h3>
<div class="review-rating">
{% for i in range(review.rating) %}
<i class="fas fa-star"></i>

23
{% endfor %} {% for i in range(5 - review.rating) %}
<i class="far fa-star"></i>
{% endfor %}
</div>
</div>
<p class="review-comment">{{ review.comment }}</p>
<div class="review-date">
<i class="far fa-calendar-alt"></i>
{{ review.created_at.strftime('%B %d, %Y') }}
</div>
</div>
{% endfor %}
</div>
{% else %}
<p class="no-reviews">No reviews yet.</p>
{% endif %}
</section>
</div>
</div>
{% endblock %}

payment.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Payment</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
</head>
<body>
<header>
<h1>Payment</h1>
</header>
<main>
<p>Payment gateway would be here (dummy page).</p>
<form method="post">
<button type="submit">Finish Booking</button>
</form>
</main>
</body>
</html>

24
signup.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sign Up - Hotel Booking</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.0.0/css/all.min.css" />
</head>
<body>
<nav class="main-nav">
<div class="nav-container">
<a href="{{ url_for('index') }}" class="nav-logo"> <i class="fas fa-hotel"></i> Hotel
Booking </a>
<div class="nav-links">
<a href="{{ url_for('index') }}">Home</a>
<a href="{{ url_for('login') }}">Login</a>
</div>
</div>
</nav>

<main class="auth-container">
<div class="auth-card">
<h1><i class="fas fa-user-plus"></i> Sign Up</h1>

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}


{% for category,
message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %} {% endif %} {% endwith %}

<form method="POST" action="{{ url_for('signup') }}" class="auth-form">


<div class="form-group">
<label for="username">Username</label>
<div class="input-with-icon">
<i class="fas fa-user"></i>
<input type="text" id="username" name="username" required />
</div>
</div>

<div class="form-group">

25
<label for="email">Email</label>
<div class="input-with-icon">
<i class="fas fa-envelope"></i>
<input type="email" id="email" name="email" required />
</div>
</div>

<div class="form-group">
<label for="password">Password</label>
<div class="input-with-icon">
<i class="fas fa-lock"></i>
<input type="password" id="password" name="password" required />
</div>
</div>

<div class="form-group">
<label for="confirm_password">Confirm Password</label>
<div class="input-with-icon">
<i class="fas fa-lock"></i>
<input type="password" id="confirm_password" name="confirm_password" required
/>
</div>
</div>

<button type="submit" class="submit-button"><i class="fas fa-user-plus"></i> Sign


Up</button>
</form>

<div class="auth-links">
<p>Already have an account? <a href="{{ url_for('login') }}">Login</a></p>
</div>
</div>
</main>

<footer class="main-footer">
<div class="footer-content">
<p>&copy; 2024 Hotel Booking. All rights reserved.</p>
</div>
</footer>
</body>
</html>

26
app.py

from flask import Flask, render_template, request, redirect, url_for, flash, jsonify, session
from werkzeug.utils import secure_filename
from database import db, Hotel, Room, Booking, Review, User
import os
from datetime import datetime, timedelta
from functools import wraps

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your-secret-key-here' # Change this to a secure secret key
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///hotel.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['UPLOAD_FOLDER'] = 'static/uploads'
app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif'}
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size

# Ensure upload directory exists


os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)

db.init_app(app)

# Function to check allowed file extensions


def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in
app.config['ALLOWED_EXTENSIONS']

# Login required decorator


def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if 'user_id' not in session:
flash('Please login to access this page', 'error')
return redirect(url_for('login'))
return f(*args, **kwargs)
return decorated_function

@app.route('/')
def index():
hotels = Hotel.query.all()
return render_template('index.html', hotels=hotels)

@app.route('/signup', methods=['GET', 'POST'])


def signup():

27
if request.method == 'POST':
username = request.form.get('username')
email = request.form.get('email')
password = request.form.get('password')
confirm_password = request.form.get('confirm_password')

if password != confirm_password:
flash('Passwords do not match', 'error')
return redirect(url_for('signup'))

if User.query.filter_by(email=email).first():
flash('Email already registered', 'error')
return redirect(url_for('signup'))

if User.query.filter_by(username=username).first():
flash('Username already taken', 'error')
return redirect(url_for('signup'))

user = User(username=username, email=email)


user.set_password(password)
db.session.add(user)
db.session.commit()

flash('Registration successful! Please login.', 'success')


return redirect(url_for('login'))

return render_template('signup.html')

@app.route('/login', methods=['GET', 'POST'])


def login():
if request.method == 'POST':
email = request.form.get('email')
password = request.form.get('password')

user = User.query.filter_by(email=email).first()
if user and user.check_password(password):
session['user_id'] = user.id
session['username'] = user.username
flash('Login successful!', 'success')
return redirect(url_for('index'))
else:
flash('Invalid email or password', 'error')
return redirect(url_for('login'))

28
return render_template('login.html')

@app.route('/logout')
def logout():
session.clear()
flash('You have been logged out', 'success')
return redirect(url_for('index'))

@app.route('/hotel/<int:hotel_id>')
def hotel_details(hotel_id):
hotel = Hotel.query.get_or_404(hotel_id)
rooms = Room.query.filter_by(hotel_id=hotel_id).all()
reviews =
Review.query.filter_by(hotel_id=hotel_id).order_by(Review.created_at.desc()).all()

# Calculate average rating


avg_rating = 0
if reviews:
avg_rating = sum(review.rating for review in reviews) / len(reviews)

return render_template(
"hotel_details.html",
hotel=hotel,
rooms=rooms,
reviews=reviews,
avg_rating=round(avg_rating, 1)
)

@app.route('/hotel/<int:hotel_id>/review', methods=['POST'])
@login_required
def add_review(hotel_id):
hotel = Hotel.query.get_or_404(hotel_id)

rating = request.form.get("rating", type=int)


comment = request.form.get("review")

if not rating or not comment:


flash("Please provide both rating and review comment", "error")
return redirect(url_for("hotel_details", hotel_id=hotel_id))

if rating < 1 or rating > 5:


flash("Rating must be between 1 and 5", "error")
return redirect(url_for("hotel_details", hotel_id=hotel_id))

29
# Check if user has already reviewed this hotel
existing_review = Review.query.filter_by(
hotel_id=hotel_id,
user_id=session['user_id']
).first()

if existing_review:
flash("You have already reviewed this hotel", "error")
return redirect(url_for("hotel_details", hotel_id=hotel_id))

review = Review(
hotel_id=hotel_id,
user_id=session['user_id'],
rating=rating,
comment=comment,
created_at=datetime.utcnow()
)

db.session.add(review)
db.session.commit()

flash("Thank you for your review!", "success")


return redirect(url_for("hotel_details", hotel_id=hotel_id))

@app.route('/book/<int:room_id>', methods=['GET', 'POST'])


@login_required
def book_room(room_id):
room = Room.query.get_or_404(room_id)
today = datetime.now().strftime('%Y-%m-%d')

if request.method == 'POST':
try:
checkin = request.form.get('checkin')
checkout = request.form.get('checkout')

if not all([checkin, checkout]):


flash('Please fill in all required fields', 'error')
return redirect(url_for('book_room', room_id=room_id))

checkin_date = datetime.strptime(checkin, '%Y-%m-%d').date()


checkout_date = datetime.strptime(checkout, '%Y-%m-%d').date()

if checkin_date >= checkout_date:


flash('Check-out date must be after check-in date', 'error')

30
return redirect(url_for('book_room', room_id=room_id))

# Calculate total price


nights = (checkout_date - checkin_date).days
total_price = room.price * nights

new_booking = Booking(
user_id=session['user_id'],
room_id=room_id,
checkin=checkin_date,
checkout=checkout_date,
total_price=total_price,
status='Pending'
)

db.session.add(new_booking)
db.session.commit()

flash('Booking successful! Proceeding to payment...', 'success')


return redirect(url_for('payment', booking_id=new_booking.id))

except Exception as e:
db.session.rollback()
flash('An error occurred while processing your booking', 'error')
return redirect(url_for('book_room', room_id=room_id))

return render_template('book_room.html', room=room, today=today)

@app.route('/my-bookings')
@login_required
def my_bookings():
bookings =
Booking.query.filter_by(user_id=session['user_id']).order_by(Booking.checkin.desc()).all()
return render_template('my_bookings.html', bookings=bookings)

@app.route('/booking/<int:booking_id>/cancel', methods=['POST'])
@login_required
def cancel_booking(booking_id):
booking = Booking.query.get_or_404(booking_id)

# Check if the booking belongs to the current user


if booking.user_id != session['user_id']:
return jsonify({'success': False, 'message': 'Unauthorized'}), 403

31
if booking.status == 'Cancelled':
return jsonify({'success': False, 'message': 'Booking is already cancelled'})

booking.status = 'Cancelled'
db.session.commit()

return jsonify({'success': True, 'message': 'Booking cancelled successfully'})

@app.route('/payment/<int:booking_id>', methods=['GET', 'POST'])


@login_required
def payment(booking_id):
booking = Booking.query.get_or_404(booking_id)

# Check if the booking belongs to the current user


if booking.user_id != session['user_id']:
flash('Unauthorized access', 'error')
return redirect(url_for('my_bookings'))

if request.method == 'POST':
# Here you would typically integrate with a payment gateway
# For now, we'll just mark the booking as confirmed
booking.status = 'Confirmed'
booking.payment_status = 'Completed'
db.session.commit()

flash('Payment successful! Your booking is confirmed.', 'success')


return redirect(url_for('my_bookings'))

return render_template('payment.html', booking=booking)

@app.route('/add_hotel', methods=['GET', 'POST'])


def add_hotel():
if request.method == 'POST':
name = request.form['name']
location = request.form['location']
description = request.form['description']

# Handle image upload


image = request.files['image']
if image and image.filename and allowed_file(image.filename):
filename = secure_filename(image.filename)
# Add timestamp to filename to make it unique
filename = f"{datetime.now().strftime('%Y%m%d_%H%M%S')}_{filename}"
image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)

32
image.save(image_path)
# Store relative path for static serving
image_url = url_for('static', filename=f'uploads/{filename}')
else:
flash('Please upload a valid image file (PNG, JPG, JPEG, or GIF)')
return redirect(url_for('add_hotel'))

new_hotel = Hotel(
name=name,
location=location,
description=description,
image_url=image_url
)
db.session.add(new_hotel)
db.session.commit()
flash('Hotel added successfully!')
return redirect(url_for('index'))

return render_template('add_hotel.html')

@app.route('/add_room/<int:hotel_id>', methods=['GET', 'POST'])


def add_room(hotel_id):
hotel = Hotel.query.get_or_404(hotel_id)
if request.method == 'POST':
type = request.form['type']
price = float(request.form['price'])
capacity = int(request.form['capacity'])
description = request.form['description']

# Handle image upload


image = request.files['image']
if image and image.filename and allowed_file(image.filename):
filename = secure_filename(image.filename)
# Add timestamp to filename to make it unique
filename = f"{datetime.now().strftime('%Y%m%d_%H%M%S')}_{filename}"
image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
image.save(image_path)
# Store relative path for static serving
image_url = url_for('static', filename=f'uploads/{filename}')
else:
flash('Please upload a valid image file (PNG, JPG, JPEG, or GIF)')
return redirect(url_for('add_room', hotel_id=hotel_id))

new_room = Room(

33
type=type,
price=price,
capacity=capacity,
description=description,
image_url=image_url,
hotel_id=hotel_id
)
db.session.add(new_room)
db.session.commit()
flash('Room added successfully!')
return redirect(url_for('hotel_details', hotel_id=hotel_id))

return render_template('add_room.html', hotel=hotel)

@app.route('/profile')
@login_required
def profile():
user = User.query.get_or_404(session['user_id'])

# Get user's bookings with room and hotel information


bookings = Booking.query.filter_by(user_id=user.id)\
.join(Room)\
.join(Hotel)\
.order_by(Booking.created_at.desc())\
.all()

# Get user's reviews with hotel information


reviews = Review.query.filter_by(user_id=user.id)\
.join(Hotel)\
.order_by(Review.created_at.desc())\
.all()

return render_template('profile.html',
user=user,
bookings=bookings,
reviews=reviews)

# Update the navigation bar in all templates to include profile link


@app.context_processor
def inject_nav_links():
return {
'nav_links': {
'home': {'url': url_for('index'), 'text': 'Home', 'icon': 'fa-home'},
'add_hotel': {'url': url_for('add_hotel'), 'text': 'Add Hotel', 'icon': 'fa-plus'},

34
'my_bookings': {'url': url_for('my_bookings'), 'text': 'My Bookings', 'icon': 'fa-calendar-
check'},
'profile': {'url': url_for('profile'), 'text': 'Profile', 'icon': 'fa-user-circle'},
'login': {'url': url_for('login'), 'text': 'Login', 'icon': 'fa-sign-in-alt'},
'signup': {'url': url_for('signup'), 'text': 'Sign Up', 'icon': 'fa-user-plus'},
'logout': {'url': url_for('logout'), 'text': 'Logout', 'icon': 'fa-sign-out-alt'}
}
}

if __name__ == '__main__':
with app.app_context():
db.create_all()
app.run(debug=True)

config.py

import os

class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'your_secret_key'
SQLALCHEMY_DATABASE_URI = 'sqlite:///hotel_booking.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False

database.py

from flask_sqlalchemy import SQLAlchemy


from datetime import datetime
from werkzeug.security import generate_password_hash, check_password_hash

db = SQLAlchemy()

class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
password_hash = db.Column(db.String(128))
created_at = db.Column(db.DateTime, default=datetime.utcnow)

# Relationships
bookings = db.relationship('Booking', backref='user', lazy=True)
reviews = db.relationship('Review', backref='user', lazy=True)

def set_password(self, password):


35
self.password_hash = generate_password_hash(password)

def check_password(self, password):


return check_password_hash(self.password_hash, password)

class Hotel(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
location = db.Column(db.String(200), nullable=False)
description = db.Column(db.Text)
image_url = db.Column(db.String(500))
created_at = db.Column(db.DateTime, default=datetime.utcnow)

# Relationships
rooms = db.relationship('Room', backref='hotel', lazy=True, cascade='all, delete-orphan')
reviews = db.relationship('Review', backref='hotel', lazy=True, cascade='all, delete-orphan')

class Room(db.Model):
id = db.Column(db.Integer, primary_key=True)
hotel_id = db.Column(db.Integer, db.ForeignKey('hotel.id'), nullable=False)
type = db.Column(db.String(50), nullable=False)
price = db.Column(db.Float, nullable=False)
capacity = db.Column(db.Integer, nullable=False)
description = db.Column(db.Text)
image_url = db.Column(db.String(500))
created_at = db.Column(db.DateTime, default=datetime.utcnow)

# Relationships
bookings = db.relationship('Booking', backref='room', lazy=True)

class Booking(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
room_id = db.Column(db.Integer, db.ForeignKey('room.id'), nullable=False)
checkin = db.Column(db.Date, nullable=False)
checkout = db.Column(db.Date, nullable=False)
total_price = db.Column(db.Float, nullable=False)
status = db.Column(db.String(20), default='Pending') # Pending, Confirmed, Cancelled
payment_status = db.Column(db.String(20), default='Pending') # Pending, Completed,
Failed
created_at = db.Column(db.DateTime, default=datetime.utcnow)

class Review(db.Model):
id = db.Column(db.Integer, primary_key=True)

36
hotel_id = db.Column(db.Integer, db.ForeignKey('hotel.id'), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
rating = db.Column(db.Integer, nullable=False)
comment = db.Column(db.Text)
created_at = db.Column(db.DateTime, default=datetime.utcnow)

models.py

from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

class Hotel(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
location = db.Column(db.String(100), nullable=False)
rating = db.Column(db.Float, nullable=False)
rooms = db.relationship('Room', backref='hotel', lazy=True)
reviews = db.relationship('Review', backref='hotel', lazy=True)

class Room(db.Model):
id = db.Column(db.Integer, primary_key=True)
room_type = db.Column(db.String(50), nullable=False)
price_per_night = db.Column(db.Float, nullable=False)
hotel_id = db.Column(db.Integer, db.ForeignKey('hotel.id'), nullable=False)

class Booking(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
email = db.Column(db.String(100), nullable=False)
checkin_date = db.Column(db.Date, nullable=False)
checkout_date = db.Column(db.Date, nullable=False)
room_id = db.Column(db.Integer, db.ForeignKey('room.id'), nullable=False)
room = db.relationship('Room', backref='bookings', lazy=True)

class Payment(db.Model):
id = db.Column(db.Integer, primary_key=True)
card_name = db.Column(db.String(100), nullable=False)
card_number = db.Column(db.String(16), nullable=False)
expiry_date = db.Column(db.String(7), nullable=False) # MM/YYYY format
cvv = db.Column(db.String(3), nullable=False)

class Review(db.Model):
37
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
rating = db.Column(db.Integer, nullable=False)
review_text = db.Column(db.Text, nullable=False)
hotel_id = db.Column(db.Integer, db.ForeignKey('hotel.id'), nullable=False)

38
REFRENCES
Google –Hotel Booking Management Online hotel reservations - Wikipedia

ChatGPT – Project guidance, structure, feature planning, and documentation support t

Perplexity – Project information, content and planning support

GitHub – Hotel Booking Management.

39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy