A simple web-based Bus Ticket Reservation System built with PHP and MySQL. This project allows passengers to register, log in, view available trips, book seats, cancel bookings, and view their booking history. It also includes an admin panel for managing buses, routes, and schedules.
- User Registration & Login (with phone number and password)
- View Available Trips – see all bus schedules with source, destination, date, and time
- Interactive Seat Selection – choose from a visual seat layout; booked seats are disabled
- Book a Ticket – instantly reserve a seat
- My Bookings – view all your tickets with booking date and status
- Cancel Booking – cancel tickets (status updates to
cancel) - Logout – end your session securely
- Dedicated admin login (default credentials:
admin/1234) - Add New Bus – specify bus number and total seats
- Add New Route – define source, destination, and distance
- Add New Schedule – assign a bus and route with departure time and date
- View All User Bookings – see every passenger's ticket details (admin-only page)
- Frontend: HTML5, CSS3 (basic styling)
- Backend: PHP 7.4+ (procedural style)
- Database: MySQL (via
mysqliextension) - Server: Apache (local) / InfinityFree (online)
/
├── index.php # Redirects to login.html
├── login.html # Passenger login form
├── login.php # Passenger login handler
├── signup.html # Passenger signup form
├── signup.php # Passenger registration handler
├── booking.php # Passenger dashboard (welcome page)
├── schedule_list.php # Shows all available trips
├── seat_layout.php # Displays seat layout for a chosen trip
├── book.php # Processes seat booking
├── my_booking.php # Shows logged-in user's bookings
├── cancel.php # Cancels a booking
├── logout.php # Destroys session and logs out
│
├── admin_login.html # Admin login form
├── admin_login.php # Admin login handler
├── admin_dashboard.php # Admin main panel
├── add_bus.php # Add new bus
├── add_route.php # Add new route
├── add_schedule.php # Add new schedule
├── alluser_view_booking.php # Admin view of all bookings
│
├── btrs.sql # Database dump (tables + sample data)
└── README.md # This file
The database is named btrs and contains the following tables:
- admin –
admin_id,username,password - passenger –
passenger_id,name,phone,password - bus –
bus_id,bus_number,total_seats,bus_type - route –
route_id,source,destination,distance - schedule –
schedule_id,bus_id,route_id,departure_time,travel_date - ticket –
ticket_id,passenger_id,schedule_id,seat_number,booking_date,status(bookorcancel)
Foreign keys link schedule to bus and route, and ticket to passenger and schedule.
- Clone or download this repository to your
htdocs(XAMPP) orwww(WAMP) folder. - Start Apache and MySQL via your control panel.
- Create the database:
- Open phpMyAdmin (
http://localhost/phpmyadmin) - Create a new database named
btrs - Import the
btrs.sqlfile (located in the project folder)
- Open phpMyAdmin (
- Update database credentials (if different from default):
- In every
.phpfile, findmysqli_connect()and adjust:$conn = mysqli_connect("localhost", "root", "", "btrs");
- In every
- Access the application:
- Open your browser and go to
http://localhost/your-folder/
- Open your browser and go to
- Upload all files to your website's root directory (e.g., via FTP or file manager).
- Create a MySQL database and user via your hosting control panel.
- Import
btrs.sqlinto that database using phpMyAdmin. - Update connection strings in all
.phpfiles with your hosting credentials:$conn = mysqli_connect("your_host", "your_user", "your_password", "your_database");
- Set the MySQL password correctly in the hosting panel (if required).
| Username | Password |
|---|---|
admin |
1234 |
You can change these directly in the admin table.
If you encounter connection issues, create a test.php file with the following content:
<?php
$conn = mysqli_connect("your_host", "your_user", "your_password", "your_database");
if (mysqli_connect_error()) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully!";
?>Access it in your browser to verify your database setup.
Add screenshots of your application here. For example:
- Passenger login page
- Available trips list
- Seat layout
- Booking confirmation
- Admin dashboard
This is a learning project, but contributions are welcome. Feel free to fork and submit pull requests for improvements (e.g., security enhancements, UI upgrade, or additional features like PDF tickets).
This project is open-source and available under the MIT License.
- Built as a college/school project to demonstrate basic PHP & MySQL skills.
- Deployed on InfinityFree for free hosting.
For any questions or suggestions, please feel free to open an issue or reach out.
Happy Travels! 🎫