A comprehensive, web-based Railway Management System built with PHP and MySQL. This application streamlines the process of booking train tickets, managing train schedules, and categorizing travel classes. It features a responsive modern UI, dynamic data fetching, and an integrated booking workflow.
- Features
- Technology Stack
- Screenshots
- Installation & Setup
- Database Schema
- Project Structure
- Future Roadmap
- Contributing
- Hero Section: Video background with a dynamic "Quick Search" widget for finding trains between cities.
- Responsive Design: Built with Bootstrap 5.3, ensuring full compatibility across mobile, tablet, and desktop.
- Animations: Smooth scroll animations using AOS (Animate On Scroll).
- Dynamic Train Listing: Trains are automatically fetched from the database and grouped by class:
- Business
- Economy
- AC Standard
- AC Sleeper
- Session Management: Secure login/logout logic with cache control to prevent back-button re-entry after logout.
- Role-Based Access: Differentiates between normal Users and Admins (displays "π Admin Panel" link for admins).
- Booking System:
- Interactive Modal for ticket reservation.
- Auto-fills train details (Name, Route, Price) when "Book Now" is clicked.
- Form validation (Client-side JS).
- Payment Integration UI: Toggles between Stripe (Card) and JazzCash (Mobile) input fields.
| Component | Technology |
|---|---|
| Backend | Core PHP (PDO), MySQL |
| Frontend | HTML5, CSS3, JavaScript (ES6) |
| Framework | Bootstrap 5.3.3 |
| Libraries | AOS (Animations) |
| Server | Apache (XAMPP/WAMP) |
- XAMPP / WAMP / MAMP (or any PHP server environment).
- MySQL Database.
-
Clone the Repository
git clone [https://github.com/your-username/railway-management-system.git](https://github.com/your-username/railway-management-system.git) cd railway-management-system -
Database Configuration
- Create a database named
railway_db. - Import the SQL schema provided below.
- Update
connect.phpwith your credentials:$host = 'localhost'; $db = 'railway_db'; $user = 'root'; $pass = '';
- Create a database named
-
Run the Project
- Place the project folder in your server's root directory (e.g.,
htdocs). - Open your browser and navigate to:
http://localhost/railway-management-system/index.php
- Place the project folder in your server's root directory (e.g.,
To ensure the application runs smoothly, execute the following SQL.
erDiagram
ROUTES ||--o{ TRAINS : "contains"
ROUTES {
int id PK
string name
}
TRAINS {
int id PK
string train_name
int route_id FK
string class
decimal price
string depart_time
int seats
}
Routes Table
CREATE TABLE routes (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL -- e.g., "Lahore to Karachi"
);
Trains Table
CREATE TABLE trains (
id INT AUTO_INCREMENT PRIMARY KEY,
train_name VARCHAR(255) NOT NULL,
route_id INT,
class VARCHAR(50) NOT NULL, -- 'Business', 'Economy', etc.
price DECIMAL(10,2) NOT NULL,
depart_time VARCHAR(50),
seats INT,
image VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (route_id) REFERENCES routes(id)
);
π‘ Pro Tip: To create an Admin User, insert a user into your
userstable and set the role to 'admin'.INSERT INTO users (username, email, password, role) VALUES ('Admin', 'admin@railway.com', 'admin123', 'admin');
Here is a breakdown of the key files and folders:
railway-system/
βββ π admin-panel/ # π The Engine Room
β βββ uploads/ # Stores train images uploaded by admins
β βββ user_dashboard.php # Customer booking history
β βββ login/register.php # Auth logic
β
βββ π pages/ # π Static Content
β βββ trains.php # Full schedule list
β βββ contact.php # Support forms
β
βββ π connect.php # π Database Connection (Do not share this!)
βββ π index.php # π Homepage (The file you viewed)
βββ π main.css # π¨ Styling & Theme
βββ π submit_booking.php # π¨ Process booking logic
βββ π README.md # π You are reading this
We have big plans for this project! Here is what we are working on next:
- Seat Selection Map: Allow users to pick specific seat numbers visually.
- Email Notifications: Send tickets via PHPMailer upon booking confirmation.
- Admin Analytics: A chart dashboard showing daily revenue using Chart.js.
- PNR Status Check: A module to track booking status using a unique ID.
Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Co-Founder β Unicodrex | Technical Lead β Skill Sprint | Trainee β CEGA
Built with β€οΈ for Academic Project