Railway Reservation Project
Railway Reservation Project
INTERNATIONAL SCHOOL
INFORMATION PRACTICES
PROJECT ON:
RAILWAY RESERVATION SYSTEM
PRINCIPAL
2|Page
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my sincere
gratitude to our teacher, Ms.Soumya Singhai
who taught and undertook the responsibility of
teaching the subject Information Pratices. I have
been greatly benefited from her classes.
I am especially indebted to our Principal
Ms.Deepali Tiwari who has always been a source
of encouragement and support and without
whose inspiration this project would not have
been a successful I would like to place on record
heartfelt thanks to her.
.
3|Page
HARDWARES AND SOFTWARESREQUIRED
HARDWARES
1. Desktop / Laptop
2. Mobile Phone
SOFTWARES
2. MySQL
1 Certificate 2
2 Acknowledgement 3
Hardwares and
3 Softwares Required 4
4 Introduction 6
6 MySQL Database 22
5|Page
7 Outputs 25
8 References 30
Objec
1. INTRODUCTIONON
Admi The project RAILWAY ON SYSTEM
proje RESERVATI Objectives of the
ct Project ctives of our
both nistrative ntricate needs
a EmpowermentThe core obje of n the railway
ecosy
are multi-faceted,
s
addressing the i
dministrators and on
User passengers withi Registration
The tem. tial details such
pr , and password.
proce ySQL database.
s as User Registration & echanisms
use Authentication oject
ccounts.
This introduces a streamlined User
in s, requiring users to
Additiprovide essen r ID, name,
o phone number, email ID em, equips
ensur formation is securely
e stored in a M
nally, robust User rains to the
Admi Authentication m train number,
n The the security and integrity of
Ad user a
admi 6|Page
ni Admin istrative Functions
min Panel, a focal point
name, origin, destination, journey distance, journey
time, seat availability, and fares.
Update Train Details: The system allows administrators to
modify existing train details, adapting to dynamic
demands
and operational changes. This includes updating
seat availability, journey details, and fare
information.
Cancel Train: In response to operational constraints or
changing
demands, administrators have the authority to cancel
trains, ensuring flexibility and adaptability in the
system.
User Interaction
User Login: The system provides a secure login interface
for registered users, requiring user ID and password for
access.
Forgot User ID:Users can retrieve forgotten user IDs
through their registered email addresses, enhancing
user experience and reducing barriers to access.
Forgot User ID
The `forgot_user_id()` function provides a
mechanism for users to retrieve their registered user
IDs via email
verification, ensuring a smooth user experience.
Train Search
The `Train_Search()` function allows users to search
for trains based on origin and destination, providing
detailed information about available trains.
Book Tickets
The `Book_Ticket(uid)` function simulates the ticket
booking process, allowing users to select trains, classes,
and
passengers for reservation.
9|Page
Cancel Tickets
The `Cancel_Ticket()` function facilitates the
cancellation of booked tickets, showcasing the
system's ability to handle modifications to user
bookings.
SOURCE CODE:
11 | P a g e
1.import random
2. from tabulate import tabulate
3. import mysql.connector as con
4.
dbo=con.connect(host="localhost",user="root",pa
ssword="admin",database="train_ reservation")
5. co=dbo.cursor()
i. # old user id
30. def old_user():
31.
dbo=con.connect(host="localhost",user="root",pa
ssword="admin",database="train_ reservation")
32. co=dbo.cursor()
12 | P a g e
33. print("\
n---------------------------------------------------------------
\n")
34. uid=input("Enter your user id: ")
35. co.execute("select user_id from user where
user_id like '{}'".format(uid))
36. b=co.fetchall()
37. c=len(b)
38. if c==0:
39. print("---------------- Your given id is not
registered -----------------")
40. print("\
n----------------------------------------------------------------
--\n")
41. print("1. Try again")
42. print("2. Forgot user id")
43. print("3. Register as a new user")
44. choose=int(input("Choose an option from
above: "))
45. if choose==1:
46. old_user()
47. elif choose==2:
48. forgot_user_id()
49. elif choose==3:
50. new_user()
51. else:
52. pas=input("Enter your password: ")
53. co.execute("select password from user
where password like '{}'".format(pas)) 54.
n=co.fetchall()
55. for i in n:
56. if pas==(i[0]):
a. print("\
n---------------------------------------------------------------
\n")
b. print("-----------Welcome back sir/ma'am
what's your plan Today??---------\n") c.
passenger_panel(uid)
19 | P a g e
i. #PASSENGER PANEL FUNCTIONALITIES
280. def Train_Search():
281.
dbo=con.connect(host="localhost",user="root",p
assword="admin",database=
"train_reservation")
282. co=dbo.cursor()
283. o=input("Enter your origin: ")
284. d=input("Enter your destination: ")
285. co.execute("select * from
train_schedule where origin like '%{}%' and
destination like '%{}
%'".format(o,d))
286. a=co.fetchall()
287. for i in a:
288. print("Train no.:
",a[0][0])
print("Train
name: ",a[0][1]) 289.
290. print("Origin:
",a[0][2])
291. print("Destination:
",a[0][3])
292. print("Journey
301. dbo.commit()
i. #BOOK TICKETS
302. def Book_Ticket(uid):
303.
dbo=con.connect(host="localhost",user="root",p
assword="admin",database=
"train_reservation")
304. co=dbo.cursor()
305. print("THIS IS OUR ALL TRAINS AVAILABLE \
n ---------------------------------------------
------------------------")
306. op="select
train_no,train_name,origin,destination from
train_schedule" 307. co.execute(op)
308. r=co.fetchall()
309. columns=[i[0] for i in co.description]
310.
print(tabulate(r,headers=columns,tablefmt="fanc
y_grid"))
311.
20 | P a g e
319. a=co.execute("select ac1_fare from
train_schedule where
train_no={}".format(trainno))
320. b=co.fetchall()
321. print(b[0][0])
322. elif typ==2:
323. a=co.execute("select sl_fare from
train_schedule where
train_no={}".format(trainno))
324. b=co.fetchall()
325. print(b[0][0])
326. elif typ==3:
327. a=co.execute("select gen_fare from
train_schedule where
train_no={}".format(trainno))
328. b=co.fetchall()
329. print(b[0][0])
330. for i in range (tcktno):
331. cus1=input("Enter customer name: ")
332. age=int(input("Enter your age: "))
333. print("--------------- For gender M=Male,
F=Female, O=Other ------------------")
334. gender=input("Enter your gender: ")
335. j=random.randint(100000,999999)
336. print("Your PNR no is: ",j)
337. cnf="Confirmed"
338. p=b[0][0]
339. co.execute("insert into booked_tickets
values
('{}',{},{},'{}',{},'{}',
{},'{}')".format(uid,j,trainno,cus1,age,gender,p,c
nf))
340. p=b[0][0]
341. amt=tcktno*p
342. print("Your total ticket price is: ",amt)
343. dbo.commit()
344. def Cancel_Ticket():
345.
dbo=con.connect(host="localhost",user="root",pa
ssword="admin",database=
"train_reservation")
21 | P a g e
35 print("******Welcome to passenger
6. panel******")
35 print("1. Train Search")
7. print("2. Book Ticket")
35 print("3. Cancel Ticket")
8. print("4. Log out")
35 choic=int(input("Enter your choice to
9. use: "))
36 if choic==1:
0. Train_Search()
36 elif choic==2:
1. Book_Ticket(uid)
36 elif choic==3:
2. Cancel_Ticket()
36 elif choic==4:
3. main_menu()
36 print("*****You are successfully logged
4. out of Passenger panel*****")
36 print("--------------------------------------------
5. -------------------------")
36
6.
36 i. #Panel functions
7. def main_menu():
36 print("-------------------------------------------
8. ----------")
36 print("********WELCOME TO TRAIN
9. RESERVATION SYSTEM********")
37 print("1. Admin panel")
0. print("2. Passenger panel")
37 print("3. Exit")
1. ch=int(input("Enter your choice: "))
while True:
if ch==1:
adminpassword()
37
2. elif
37 ch==2:
3. user_p
37 anel()
4.
22 | P a g e
MySQl
DATAbASE:
23 | P a g e
TRAIN TABLE:
PASSENGER LIST :
24 | P a g e
USER DETAILS :
BOOKED_TICKETS:
2
5|Page
OUTPUTS:
26 | P a g e
TRAIN RESERvATION MAIN PAgE:
27 | P a g e
THE ADMIN lOgIN PANEl:
28 | P a g e
CANCEl TICKET:
bOOKINg TICKETS :
29 | P a g e
SEARCH TRAIN:
30 | P a g e
REFERENCES:
2.PYTHON
https://www.python.org/
3.MySQL
https://www.mysql.com/
4.KV Coders
https://kvcoders.in
79874: 5. IRCTC:
https://www.irctc.co.in/nget/ train-search
31 | P a g e