Python Hotel System Source Code

Hotel Management System Source Code Using Python Tkinter And MySQL Database

Hotel Management System Source Code Using Python Tkinter And MySQL Database

This project uses Python, CustomTkinter/Tkinter, and a MySQL database to create a desktop-based hotel system that handles authentication, customer records, room management, and reservations in a clean, modern interface. 

The application starts from a simple main.py entry point, launches a login form, and then opens the full hotel dashboard after successful authentication.

Watch This Full Demo


1. Application startup and architecture

The application begins in main.py, where a LoginForm object is created and run. The login form is the gateway into the rest of the system. Once the user is authenticated, the login window hides itself and launches a combined application class that merges the dashboard shell with the customer, room, and reservation management modules. That means the final running app is one integrated interface built from multiple mixins instead of several unrelated programs.

Behind the scenes, the architecture is split into clear layers. The DatabaseManager handles connections and queries, the Customer, Room, and Reservation classes represent business entities, and the GUI modules focus on user interaction. This separation is important because it keeps UI logic, database logic, and business logic easier to maintain.

2. Login form

login form

The first form users see is the Login Form. It is built with CustomTkinter and designed as a modern card-style window centered on the screen. The form includes a branded header with the title HOTEL MANAGEMENT, a subtitle System Login, a username field, a password field, a SHOW/HIDE password toggle button, a LOGIN button, and a status label for feedback messages.

System Login

From a functionality point of view, the login form validates that both username and password are entered before attempting authentication. If one is missing, it shows an error message. If both are present, it displays a temporary “Logging in.” message, disables the login button, and verifies the credentials through the database manager. On success, it shows “Login successful!” and opens the main hotel system. On failure, it shows “Invalid username or password” and re-enables the button. The form also supports keyboard shortcuts: pressing Enter triggers login, while Ctrl+H toggles password visibility.

An interesting detail is that the file contains a commented-out info panel for default credentials. That means the developer considered exposing starter login information in the UI, but left it disabled in the current version.

3. Database connection and authentication

Database connection and authentication

As soon as the login form is initialized, it creates a DatabaseManager. This class connects to MySQL using the values from the configuration file. If the connection succeeds, it prints a success message and ensures the users table exists. If the table is empty, it automatically inserts a default admin user from configuration.

For security, passwords are not compared as plain text. The system hashes passwords using SHA-256, then checks the username and hashed password against the database. Query execution uses parameterized SQL, which is important for preventing SQL injection. The same manager class also provides helper methods to execute write queries and fetch records as dictionaries, making database interaction much easier throughout the project.

4. Main application shell

Main application shell

After login, the user enters the main application window. This is the core frame that holds the entire hotel system. It includes a top header area, a horizontal navigation bar, and a content area that switches between different pages. The header shows the app name, a subtitle listing the main modules, a signed-in user chip, and a Logout button. The navigation uses pill-style buttons for Dashboard, Customers, Rooms, and Reservations, with active-page highlighting for a more polished experience.

When switching sections, the application clears the old content frame and rebuilds the page for the selected module. This keeps navigation simple and makes the app feel like a single coherent desktop system rather than separate windows glued together.

5. Dashboard

Dashboard

The Dashboard is the first page shown after login. Its role is to provide a quick summary of hotel activity. It displays a title, a subtitle explaining that it offers an overview of rooms, customers, and reservations, and then shows statistics cards. These cards calculate and display values such as Total Rooms, Available Rooms, Occupied Rooms, Customers, and Active Reservations. The values are computed directly from the in-memory room, customer, and reservation objects loaded from the database.

The Dashboard Page

This is a useful design choice because it gives hotel staff an immediate snapshot of system status without requiring them to open each management module individually. Even though the dashboard is visually simple, it acts as the operational summary of the whole application.

6. Customer Management page

Customer Management page

The Customer Management module is responsible for maintaining guest records. According to the code, this page supports viewing customers in a table, searching through customer data, adding new customers, editing existing customers, and deleting records. It also preserves the current search text between page changes, which improves usability for staff who are repeatedly moving between modules.

Customer Management

The customer page contains a search area, a results count label, and a scrollable table. The table uses six columns: ID, Name, Email, Phone, Address, and Actions. Search works across all customer fields in a case-insensitive way, and the UI rebuilds the table only after the text actually changes, using a debounced update pattern to avoid refreshing on every keystroke. If no records match, the page shows a clear empty-state message: No customers found.

Add Customer form

Add Customer form
The Add Customer form is opened through a modal dialog. It reuses the same internal form logic as the edit screen, which is a smart way to reduce duplicated code. When adding a customer, the system validates that Customer ID and Customer Name are present, and it also checks that the entered customer ID does not already exist. If validation passes, the system inserts the new customer into MySQL, adds the customer to the in-memory dictionary, shows a success message, closes the dialog, and refreshes the customer page.

Edit Customer form

Edit Customer form

The Edit Customer form uses the same dialog layout, but it is pre-filled with the selected customer’s information. On submission, the code updates the customer’s name, email, phone, and address in the database, then updates the in-memory object to keep the UI synchronized. After that, it shows a success message and refreshes the table.

Delete Customer confirmation

Delete Customer confirmation

Deleting a customer is handled through a confirmation dialog titled Delete Customer. The dialog displays the selected customer’s name and ID before removal. This is a good usability feature because it reduces accidental deletions and makes the action explicit.

7. Room Management page

Room Management page

The Room Management page is one of the strongest modules in the project because it combines search, filters, status display, and CRUD operations in one screen. The code explicitly states that this page can display rooms in a searchable and filterable table, add new rooms, edit room details, delete selected rooms, toggle room availability status, filter by status and type, and search by room number, type, status, or price.

Room Management

The page layout is divided into three main cards: a header card, a filter card, and a table card. The header contains the page title plus action buttons. The filter area lets the user filter by All, Available, or Occupied, choose a room type, and use a search box. The table itself is scrollable and uses the columns Room Number, Type, Price, Status, and Actions. The status column is styled as a colored badge, making it easy to distinguish available rooms from occupied ones at a glance.

The search system is also well thought out. It is debounced, meaning the interface waits briefly before refreshing results while the user types. Filtering can be stacked, so a user can view only occupied suites, or all doubles matching a certain search term, for example. If the filter returns no results, the page shows an empty-state message instead of leaving the table blank.

Add Room form

Add Room form

The Add Room dialog includes fields for Room Number, Room Type, and Price. Validation ensures that the room number is present, unique, that a room type has been selected, and that the price is numeric and greater than zero. If everything is valid, the system inserts the new room into the database with a default status of Available, updates the in-memory room dictionary, shows a success message, and refreshes the room list.

Edit Room form

Edit Room form

The Edit Room dialog preloads the room’s current values. Unlike the add form, the room number field is disabled, meaning the room’s identifier cannot be changed after creation. The user can update the room type and price, which is a sensible restriction because room numbers often act as stable keys in hotel systems.

Delete Room confirmation

Delete Room confirmation

The Delete Room action opens a confirmation modal showing the room number and room type before deleting it. Once confirmed, the room is removed from MySQL, removed from the in-memory dictionary, the current selection is cleared, and the room list is refreshed.

8. Reservation Management page

Reservation Management page

The Reservation Management module handles booking logic, which is the most business-critical part of the application. The code lists its major features clearly: viewing reservations in a modern table, filtering by status, sorting by check-in or check-out date, creating new reservations with overlap prevention, cancelling active reservations, deleting cancelled reservations, and automatically updating room status for the current day only.

Reservation Management

When the page opens, it defaults to showing All reservations, sorted by Check In in ascending order. The page includes a header card titled Reservation Management, a subtitle explaining that users can create, review, cancel, or delete reservations, and a New Reservation button. Below that is a filter/sort area and then the reservation table.

The reservation table displays the reservation ID, customer name, room number, check-in date, check-out date, total amount, status, and actions. The status is rendered as a colored badge: active reservations appear in a success style, cancelled ones in a danger style, and other states use a neutral look. The actions column is also status-aware: Active reservations show a Cancel button, Cancelled reservations show a Delete button, and other statuses show a dash.

New Reservation form

New Reservation form

The New Reservation dialog asks for Reservation ID, Customer, Room, Check In Date, and Check Out Date. The save logic is careful and realistic. It validates that the reservation ID is present and unique, confirms that a customer and room have been selected, ensures the room exists, checks that both dates are provided in YYYY-MM-DD format, and requires the check-out date to be later than the check-in date. It then checks whether the selected room already has an overlapping active reservation. Only if all of those conditions pass will the reservation be created.

The overlap logic is especially important. The code compares date ranges and treats checkout day as non-overlapping, which is correct for hotel bookings because a room can usually be reused on the checkout date after the guest leaves. It only checks active reservations, so cancelled bookings do not block future reservations.

After validation, the system calculates total_amount as the number of nights multiplied by the selected room’s nightly price, inserts the reservation into the database with the status Active, stores it in memory, and updates the room status to Occupied only if the reservation actually includes the current date. That last part is a strong design choice because it separates future bookings from rooms that are physically occupied today.

Cancel Reservation confirmation

Cancelling a reservation opens a confirmation dialog. If confirmed, the database record is updated to Cancelled, the in-memory reservation object is updated too, and the system recalculates whether the room should still be marked Occupied today. If no other active reservation covers the current date, the room becomes Available; otherwise, it stays occupied. This prevents incorrect room status changes when multiple reservation situations exist.

Delete Reservation confirmation

Delete Reservation confirmation

Deleting a reservation is restricted to reservations already marked Cancelled. If the user tries to delete any other status, the system shows an error. For cancelled reservations, it opens a confirmation dialog showing the reservation ID and customer name, warns that the action cannot be undone, then removes the record from both the database and memory before refreshing the page.

9. Data models

Data models

The project also uses simple but effective data model classes for Customer, Room, and Reservation. These classes act as in-memory representations of database rows and also provide small helper methods. For example, Room exposes availability helpers, while Reservation provides methods like is_active(), cancel(), and complete(). These model classes make the rest of the application easier to read because the GUI code works with meaningful objects instead of raw tuples or dictionaries everywhere.

10. Database schema

Database schema

The MySQL schema supports the application cleanly. The customers table stores guest identity and contact fields, the rooms table stores room number, room type, price, and current status, and the reservations table links customers to rooms with dates, amount, and status. Foreign key constraints connect reservations to both customers and rooms, which helps preserve referential integrity. The SQL dump also includes sample records, showing how the application can be preloaded with demo hotel data.

Get the Full Project Source Code

If you enjoyed this project and would like to get the full source code, you can support us by purchasing it for just $5. Your support truly means a lot to us and helps us continue creating more useful, creative, and inspiring projects like this one. Every small contribution helps us keep building, improving, and sharing more with you. 







PHP Address Book Project Source Code

Address Book Project In PHP With Source Code

PHP Address Book Project Source Code

In this PHP Address Book project demo, you will see what you can do with this Address Book system built using PHP, Javascript programming language, and MySQL database. 

This project allows you to manage contacts efficiently, providing you with a simple and intuitive interface for adding, editing, and deleting contacts. 

With its search functionality, you can easily find the contact you're looking for. 

Tools:

  • - PHP Programming Language.
  • - JavaScript Programming Language.
  • - HTML & CSS.
  • - MYSQL Database.
  • - Font-Awesome.
  • - Visual Studio Code Editor.

Watch This Full Demo

if you want the source code click on the download button below



1 - Login Page

This form allows users to login to the application and manage their contacts.

Login Page

If the user enters incorrect information, an error message will be displayed.
Login Error
Before you can login, you need to create an account first.
And to do that just click on the signup link under the login button.

2 - SignUp Page

The signup requires users to provide their personal information to create an account.
SignUp Page

If the user enters an email address that already exists in our database, an error message will be displayed.
SignUp Page - Email Error

and if the user enter a password that has less than 8 characters an error message will show up.
SignUp Page - Password Error

If the user enters the correct information, a success message will be displayed.
SignUp Page - Success


2 - Groups Page

This page contains a table with all of the user's contact groups.
Groups Page

If the user wants to add a new group, they can do so by clicking the plus circle at the bottom.
add a new group

add a new group



The user can return to the groups page by clicking the 'Groups' button.
If the user wants to edit or remove a specific group, they can simply click on the corresponding edit or trash icon for that group.

Edit Group
Edit Group

Edit Group


Remove Group
Remove Group

Delete Group


2 - Contacts Page

This page displays a table of all user contact information.

Contacts Page

It also contains a search bar so the user can easily find the contact information they need. For example, if we were searching for the contact information for someone named John, we could enter 'John' into the search bar.
Contacts Page - Search


If the user wants to add a new contact, they can do so by clicking the black plus button.

add a new contact


the list is populated with the user groups.

Goups List

If the user enters the contact info and clicks the 'Add' button, a success message will appear.

Add Contact




Similar to the groups page, the user can return to the contacts page by clicking the 'Contacts' button..
And to edit or remove a contact, the user can simply click on the corresponding edit or trash icon located next to the contact's information..


Edit Contact
Edit Contact


Edit Contact



Remove Contact

Remove Contact

Remove Contact


The source code is packaged as a RAR file and is available for purchase at a cost of just $5.
By purchasing the source code, you'll not only gain access to this project source code, but you'll also be supporting our works efforts. Your support will help us continue to improve and create more projects.
Simply click the download button below to get started.


if you want the source code click on the download button below






Delivery: Instant Source Code Download.






PHP Students Management System Source Code

Students Management System In PHP With Source Code

Students Management System In PHP With Source Code


in this php project demo, we will discover the capabilities of a Students Management System.
This project is built using PHP and JavaScript programming languages, along with a MySQL database.
this students system allow users to manage students, courses, enrollments and marks.

Tools:
- Apache server.
- PHP + JavaScript programming Language.
- Html + Css.
- font awesome library.
- MySQL Database.


if you want the source code click on the download button below




1 - Login Page

Students Management System In PHP - Login Page

this form allow users and admin to login into the system.

login form


If you enter an invalid email or password, an error message will be displayed, alerting you to the incorrect login credentials.

login form - incorrect password

login form - incorrect email


if you enter the correct email and password, you will be redirected to the Dashboard page.

2 - Dashboard Page


Students Management System In PHP - Dashboard Page


the dashboard page contains the following sections:
1 - SideBar Menu: The page, along with other pages, features a sidebar menu section. 
This menu is included from the "common-section.php" file using a PHP include statement. 
This menu include a logout button so users can quit the application.
The visibility of the "Users" link depends on the user's role. 
If the user is an admin, the link is visible; otherwise, it is hidden.

SideBar Menu For Admins
Admin


if the user type is an admin the link to manage users will be visible, and if it's not an admin it will be invisible.

SideBar Menu For Users
User


2 - Analytics Boxes: The page showcases a set of boxes that provide essential analytics information. Each box represents a different metric and consists of an icon, a title, and a corresponding value.

The values displayed in these boxes are retrieved from PHP variables and dynamically populated using PHP code (e.g., <?= count($students)?>).


Analytics Boxes



3 - Students Page

Students Management System In PHP - Students Page

This Student Dashboard provides a view of student demographics, including name, birthdate, gender, contact information, and more.

The dashboard offers insights into the gender distribution among enrolled students, allowing administrators to analyze gender diversity within the student body.

Student Dashboard 1
Student Dashboard 2


Add Student.

To add a new student, click on the 'Add New Student' button. 
A modal will appear to collect the student's information. 
If the insertion is successful, a message will appear to notify the user using PHP cookies.

Add New Student

Student Added



Edit Student.

To edit a student, click the edit button in the table corresponding to the student you want to edit. 
A modal will appear to collect the new student's information. 
If the update is successful, a message will appear to notify the user using PHP cookies.

Edit Student

Student Edited


Remove Student.

Like for the edit, click the 'Delete' button to remove a student.

Remove Student

Student Removed



Search Students.

To search for students, you can utilize the search bar. 
Users can search by gender, a specific value, or both.

Search For Female Students
female students

Search For Male Students
male students

Search Students
Search Students ('ha' query)



Student Enrolled In:

To view the courses a specific student is enrolled in, click on the 'view' link in the table. 
The courses will be displayed in a table below the student's information. 
The table shows the courses and the student's mark on them if available; if not, a button to set the mark will be displayed.

Student Courses


Set Student Mark.

To set a student's mark for a course, click on the 'Set Mark' button in the table. 
A modal will appear, allowing you to enter the student's mark, status (Pass or Fail), and a remark. 
If a student already has a mark for the course, the 'Set Mark' button will not be visible


Set Student Mark

Student Mark Added

Student Courses With Marks


4 - Courses Page

Students Management System In PHP - Courses Page

This Course Dashboard displays a table with information about each course, including ID, name, description, duration, instructor, level, fee, and actions (such as editing or deleting).
Users can add new courses, edit existing courses, and remove courses using modal forms.


Course Dashboard 1
Course Dashboard 2


Add Course.

To add a new course, click on the 'Add New Course' button. 
A modal will appear to collect the course's information. 
If the insertion is successful, a message will appear to notify the user using PHP cookies.

Add New Course

Add New Course 2

Course Added


If course name already exists.

course name already exists


Edit Course.

To edit a course, click the edit button in the table corresponding to the course you want to edit. 
A modal will appear to collect the new course's information. 
If the update is successful, a message will appear to notify the user using PHP cookies.

Edit Course

Course Edited


Remove Course.

Like for the edit, click the 'Delete' button to remove a course.

Remove Course

Course Removed


Search Courses.

To search for courses, you can utilize the search bar. 
Users can search by level (beginner, intermediate, advanced), a specific value, or both.


Search Courses 1

Search Courses 2

Search Courses 3

Search Courses 4

View Students Enrolled In Selected Course:

To view the students enrolled in a specific course, click on the 'view' link in the table. 
The students will be displayed in a table below the course information. 
The table shows the students and their marks on this course, if available; if not, a button to set the mark will be displayed.

students enrolled in a course

courses - add mark

courses - add mark 2

 

5 - Enrollments Page

Students Management System In PHP - Enrollments Page


This Enrollments Dashboard displays a table with information about each enrollment, including enrollment ID, student name, course name, enrollment date, enrollment status, and action buttons for editing, deleting, and marking.
Users can add new enrollments, edit existing enrollments, and remove enrollments using modal forms.
It displays total enrollments, active enrollments, and inactive enrollments in separate cards.


Enrollments Dashboard 1
Enrollments Dashboard 2



Add Enrollment.

To add a new course, click on the 'Add New Enrollment' button. 
A modal will appear to collect the enrollment's information. 
If the insertion is successful, a message will appear to notify the user using PHP cookies.

Add Enrollment

Enrollment Added


Enrollement Already Exists:

Before adding a new enrollment, we will verify that an active enrollment for the same student and course does not already exist in the records.

Enrollement Already Exists



Edit Enrollement.

To edit a enrollment, click the edit button in the table corresponding to the enrollment you want to edit. 
A modal will appear to collect the new enrollment's information. 
If the update is successful, a message will appear to notify the user using PHP cookies.

Edit Enrollement

Enrollement Edited


Remove Enrollement.

Like for the edit, click the 'Delete' button to remove an enrollment.

Remove Enrollement

Enrollement Removed


Add Enrollement Mark.

To set a mark for an enrollment, click on the 'Set Mark' button in the table.

Add Enrollement Mark

Add Enrollement Mark 2

If an enrollment already has a mark, the 'Set Mark' button will be disabled.

Enrollements



Search Enrollement.

To search for enrollments, you can utilize the search bar. 
Users can search by status (acive, inactive), a specific value, or both.

Search Enrollement

Search Enrollement 2

Search Enrollement 3


6 - Marks Page

Students Management System In PHP - Marks Page


This Marks Dashboard displays a table with information about each Mark.
Users can edit existing marks, and remove marks using modal forms.
It also display statistics such as the highest mark, lowest mark, and average mark based on the retrieved marks data.
To add a mark you can use the Student, Course, Enrollment Dashboard.

Marks Dashboard


Edit Mark.

To edit a mark, click the edit button in the table corresponding to the mark you want to edit. 
A modal will appear to collect the information for the new mark. 
Users can only edit the mark value, status, and remark; the enrollment ID remains the same

Edit Mark

Mark Edited



Remove Mark.

To remove a mark, simply click the 'Delete' button in the table next to the mark you wish to remove.

Remove Mark

Mark Removed



Search Mark.

You can search by status (pass or fail) or by a specific value.

Search Mark - fail
fail

Search Mark - pass
pass

Search Mark - query
query "ha"


8 - Users Page

Students Management System In PHP - Users Page


Users are redirected to this page only if they are logged in as an administrator (admin role).
All users stored in the database are retrieved and displayed in a table format.


Users Dashboard



Add User:

Administrators can add new users by filling out a form. 
They need to provide the user's name, email, phone number, password, confirm password, and user type (admin or user).
When adding or editing a user, the system checks if the entered password and confirm password fields match before submission.

Add User

Add User - passwords do not match

User Added



Administrators cannot add or edit a user email address with one that already exists.

user email address already exists


Edit User:

Existing users can be edited by clicking the "Edit" button next to their details in the table. 
This opens a form with pre-filled fields, allowing administrators to modify the user's information.

Edit User

User Edited


Remove User:

Administrators can remove users by clicking the "Delete" button next to their details in the table. 
A confirmation modal appears before deleting the user.

Remove User

User Removed


Search User:

Users can search for specific users by name and user type (admin or user). 
The search results are displayed dynamically on the page.

Search Users

Search User 2

Search User 3




if you want the source code click on the download button below