ANUSHKA COMPUTER - Removed
ANUSHKA COMPUTER - Removed
2024 - 25
PROJECT TOPIC :
➢ RAILWAY RESERVATION SYSTEM
Submitted By:
Name: ANUSHKA
Class: XII-A
Roll no: 25612451
Submitted To: Mrs. RITIKA BISHT,
PGT(CS)
1|Page
CERTIFICATE
This is to certify that ANUSHKA of class:
XII A of PM SHRI KENDRIYA VIDYALAYA ITBP
SEEMADWAR has done her project on
RAILWAY RESERVATION SYSTEM under my
supervision. She has taken interest and has
shown at most sincerity in completion of this
project.
I certify this project up to my expectation &
as per guidelines issued by CBSE, NEW DELHI.
PRINCIPAL
3|Page
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my sincere
gratitude to our teacher, Mrs. RITIKA BISHT who
taught and undertook the responsibility of
teaching the subject computer science. I have
been greatly benefited from her classes.
I am especially indebted to our Principal MR.
SANJAY KUMAR 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 him.
Finally, I would like to express my sincere
appreciation for all the other students in my
batch their friend & the fine time that we all
shared together.
4|Page
HARDWARES AND SOFTWARES
REQUIRED
HARDWARES
1. Desktop / Laptop
2. Mobile Phone
SOFTWARES
5|Page
CONTENTS
S.No. Topic Page No.
1 Certificate 2
2 Acknowledgement 3
Hardwares and
Softwares
3 Required 4
4 Introduction 6
6 MySQL Database 22
7 Outputs 25
8 References 30
6|Page
INTRODUCTION
➢ The project RAILWAY RESERVATION SYSTEM
Objectives of the Project
1. Administrative EmpowermentThe core
objectives of our project are multi-faceted,
addressing the intricate needs of both
administrators and passengers within the
railway ecosystem.
User Registration & Authentication
The project introduces a streamlined User
Registration process, requiring users to
provide essential details such as user ID,
name, phone number, email ID, and
password.
This information is securely stored in a
MySQL database. Additionally, robust User
Authentication mechanisms ensure the
security and integrity of user accounts.
Administrative Functions
The Admin Panel, a focal point of the
system, equips administrators with
indispensable tools:
Add Train: Administrators can add new trains
to the system, specifying crucial details such as
train number, 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.
2. Enhancing Customer Experience
The Customer Panel is designed with the end-
user in mind, focusing on providing an intuitive
and user-friendly interface for seamless ticket
booking and management.
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.
➢ Old User Authentication
The `old_user()` function verifies user credentials,
allowing access to registered users and guiding them
through the system functionalities.
➢ 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.
➢ Cancel Tickets
The `Cancel_Ticket()` function facilitates the
cancellation of booked tickets, showcasing the
system's ability to handle modifications to user
bookings.
i.#FORGET USER ID
22. def forgot_user_id():
23. dbo=con.connect(host="localhost",user="root",password="adm
in",database="train_ reservation")
24. co=dbo.cursor()
25. email=input("Enter your registered email: ")
26. co.execute("select user_id from user where email_id like
'{}'".format(email))
27. emel=co.fetchall()
28. for i in emel:
29. print("Your user_id is: ",(i[0]))
i. # old user id
30. def old_user():
31. dbo=con.connect(host="localhost",user="root",password="adm
in",database="train_ reservation")
32. co=dbo.cursor()
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_i
d() 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)
#ADD TRAIN
i.
78. def add_train():
79. dbo=con.connect(host="localhost",user="root",password="
admin",database="train_ reservation")
80. co=dbo.cursor()
81. print("---------------------------------------------------------------------")
82. a=int(input("Enter train no: "))
83. b=input("Enter train name: ")
84. c=input("Enter train origin: ")
85. d=input("Enter train destination: ")
86. e=int(input("Enter train journey distance: "))
87. g=input("Enter train journey time: ")
88. h=int(input("Enter no of seats in AC: "))
89. i=int(input("Enter no of seats in SL: "))
90. j=int(input("Enter no of seats in GEN: "))
91. k=int(input("Enter price of AC: "))
92. l=int(input("Enter price of SL: "))
93. m=int(input("Enter price of GEN: "))
94. n=input("Enter days available: ")
95. print("---------------------------------------------------------------------")
96. co.execute("insert into train_schedule values
({},'{}','{}','{}',{},'{}',{},{},{},{},{},{},'{}')".format(a,b,c,d,e,g,h,i,j,k,l,m,
n))
97. print("*********You have added a new train details
successfully************")
98. dbo.commit()
i. # To Update train
name 130. elif x==2:
131. print("---------------------------------------------------------------------")
132. print("**********YOU ARE GOING TO UPDATE TRAIN
NAME***********")
133. tno=int(input("Enter train no whose name you want to
update: "))
134. tname=input("Enter updated train name: ")
135. co.execute("update train_schedule set train_name='{}'
where train_no={}".
format(tname,tno))
136. print("*******UPDATED SUCCESSFULLY********")
137. print("---------------------------------------------------------------------")
138. dbo.commit()
139. return
i. # To Update train
origin 140. elif x==3:
141. print("---------------------------------------------------------------------")
142. print("**********YOU ARE GOING TO UPDATE TRAIN
ORIGIN***********")
143. tno=int(input("Enter train no whose origin you want to
update: "))
144. orgn=input("Enter updated train origin: ")
145. co.execute("update train_schedule set origin='{}' where
train_no={}".
format(orgn,tno))
146. print("*******UPDATED SUCCESSFULLY********")
147. print("---------------------------------------------------------------------")
148. dbo.commit()
149. return
i. # To Update train
destination 150. elif x==4:
151. print("---------------------------------------------------------------------")
152. print("**********YOU ARE GOING TO UPDATE TRAIN
DESTINATION***********")
153. tno=int(input("Enter train no whose destination you want to
update: "))
154. td=input("Enter updated train destination: ")
155. co.execute("update train_schedule set destination='{}'
where train_no={}".
format(td,tno))
156. print("*******UPDATED SUCCESSFULLY********")
157. print("---------------------------------------------------------------------")
158. dbo.commit()
159. return
i. # To Update journey
distance 160. elif x==5:
161. print("---------------------------------------------------------------------")
162. print("**********YOU ARE GOING TO UPDATE JOURNEY
DISTANCE ***********")
163. tno=int(input("Enter train no whose journey dist you want to
update: "))
164. tjd=input("Enter updated journey dist: ")
165. co.execute("update train_schedule set
journey_distance='{}' where train_no={}". format(tjd,tno))
166. print("*******UPDATED SUCCESSFULLY********")
167. print("---------------------------------------------------------------------")
168. dbo.commit()
169. return
i. #ADMIN PANEL
OPTIONS 261. def
admin_panel():
262. while True:
263. try:
264. print("---------------------------------------------------------------------")
265. print("******Welcome to admin panel******")
266. print("1. Add train")
267. print("2. Update details")
268. print("3. Cancel Train")
269. print("4. Log out")
270. opt=int(input("Choose your option: ")) 271. if opt==1:
a. add_train()
272. elif opt==2:
a.
update_details() 273.
elif opt==3:
a. cancel_train()
274. elif opt==4:
a. print("**********You are out of admin panel***********")
b. print("---------------------------------------------------------------------")
c. main_menu()
275. except InvalidOptionError as e:
276. print(f"Error: {e}") 277. except:
278. print("**********Choose a correct option***********")
279. print("---------------------------------------------------------------------")
i. #PASSENGER PANEL
FUNCTIONALITIES 280. def Train_Search():
281. dbo=con.connect(host="localhost",user="root",password="
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])
289. print("Train name: ",a[0][1])
290. print("Origin: ",a[0][2])
291. print("Destination: ",a[0][3])
292. print("Journey distance: ",a[0][4])
293. print("Available days: ",a[0][12])
294. print("total time: ",a[0][5])
295. print("Seats in ac1: ",a[0][6])
296. print("Seats in sl: ",a[0][7])
297. print("Seats in GEN: ",a[0][8])
298. print("Fare of ac1: ",a[0][9])
299. print("Fare of sl: ",a[0][10])
300. print("Fare of gen: ",a[0][11])
301. dbo.commit()
i. #BOOK TICKETS
302. def Book_Ticket(uid):
303. dbo=con.connect(host="localhost",user="root",password="
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="fancy_grid"))
311. print("---------------------------------------------------------------------\n\n")
312. trainno=int(input("Enter your Train no: "))
313. tcktno=int(input("Enter no of seats you want to book: "))
314. print("1. AC TICKET")
315. print("2. SL TICKET")
316. print("3. GEN TICKET")
317. typ=int(input("Enter your choice of class: ")) 318. if
typ==1:
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()
i. #PASSENGER
PANEL 351. def
passenger_panel(uid):
352.
dbo=con.connect(host="localhost",user="root",password="ad
min",database= "train_reservation") 353. co=dbo.cursor() 354.
while True:
355. print("---------------------------------------------------------------------")
356. print("******Welcome to passenger panel******")
357. print("1. Train Search")
358. print("2. Book Ticket")
359. print("3. Cancel Ticket")
360. print("4. Log out")
361. choic=int(input("Enter your choice to use: ")) 362. if
choic==1: 363. Train_Search() 364. elif choic==2:
365. Book_Ticket(uid) 366. elif choic==3: 367.
Cancel_Ticket() 368. elif choic==4:
369. main_menu()
370. print("*****You are successfully logged out of Passenger
panel*****")
371. print("---------------------------------------------------------------------")
i. #Panel
functions 372. def
main_menu():
373. print("-----------------------------------------------------")
374. print("********WELCOME TO TRAIN RESERVATION
SYSTEM********")
375. print("1. Admin panel")
376. print("2. Passenger panel")
377. print("3. Exit")
378. ch=int(input("Enter your choice: ")) 379. while True:
380. if ch==1:
381. adminpassword()
382. elif ch==2:
383. user_panel()
388. main_menu()
MySQl
DATAbASE:
TRAIN TABLE:
PASSENGER LIST :
USER DETAILS :
BOOKED_TICKETS:
OUTPUTS:
TRAIN RESERvATION MAIN
PAgE:
THE ADMIN lOgIN PANEl:
CANCEl TICKET:
bOOKINg TICKETS :
SEARCH TRAIN:
REFERENCES:
1. CLASS 11th& 12th Computer
Science Book
(SUMITA ARORA)
2.PYTHON https://www.python.org/
3.MySQL https://www.mysql.com/
4.KV Coders https://kvcoders.in
5. IRCTC:
https://www.irctc.co.in/nget/ train-
search