mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root')cursor = mycon.cursor()
mycon.autocommit = True
s1 = "create database railway"
cursor.execute(s1)
s1 = """create table railway(
name varchar(100),
phno varchar(15) primary key,
age int(4),
gender varchar(50),
from_f varchar(100),
to_t varchar(100),
date_d varchar(20)
)"""
cursor.execute(s1)
s1 = """create table user_accounts(
fname varchar(100),
lname varchar(100),
user_name varchar(100),
password varchar(100) primary key,
phno varchar(15),
gender varchar(50),
dob varchar(50),
age varchar(4)
)"""
cursor.execute(s1)
def menu():
print('1.YES')
print('2.NO')
ch = int(input('DO YOU WANT TO CONTINUE OR NOT:'))
while ch == 1:
print('WELCOME TO ONLINE RAILWAY RESERVATION SYSTEM')
print('1.SIGN IN')
print('2.SIGN UP')
print('3.DELETE ACCOUNT')
print('4.EXIT')
ch1 = int(input('ENTER YOUR CHOICE:'))
if ch1 == 1:
a = checking()
if a:
print('WELCOME')
main()
else:
continue
elif ch1 == 2:
a = checking_1()
if a:
main()
else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1 == 3:
c = checking_2()
if c:
print('ACCOUNT DELETED')
continue
else:
print('YOUR PASSWORD OR USER_NAME IS INCORRECT')
continue
elif ch1 == 4:
print('THANK YOU')
break
else:
print('ERROR 404:PAGE NOT FOUND')
break
def main():
print('1.yes')
print('2.no')
c = int(input("do you want to continue or not:"))
while c == 1:
print('''1.TICKET BOOKING
2.TICKET CHECKING
3.TICKET CANCELLING
4.ACCOUNT DETAILS
5.LOG OUT''')
ch = int(input('enter your choice:'))
if ch == 1:
ticket_booking()
elif ch == 2:
ticket_checking()
elif ch == 3:
ticket_cancelling()
elif ch == 4:
checking_3()
elif ch == 5:
print('THANK YOU')
break
else:
print('ERROR 404: ERROR PAGE NOT FOUND')
def ticket_booking():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
nm = input('enter your name:')
phno = input('enter your phone number:')
age = int(input('enter your age:'))
print('''M=MALE
F=FEMALE
N=NOT TO MENTION''')
gender = input('enter your gender:').upper()
fr = input('enter your starting point:')
to = input('enter your destination:')
date1 = input('enter date(dd):')
date2 = input('enter month(mm):')
date3 = input('enter year(yyyy):')
date = f
"{date1}/{date2}/{date3}" a = {'M': 'MALE', 'F': 'FEMALE', 'N': 'NOT TO MENTION'}
v = a[gender]
s1 = f"insert into railway values ('{nm}', '{phno}', {age}, '{v}', '{fr}', '{to}', '{date}')"
cursor.execute(s1)
print('BOOKED SUCCESSFULLY')
def ticket_checking():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
print('1.yes')
print('2.no')
ch = int(input("do you want to continue or not:"))
if ch == 1:
phno = input('enter your phone number:')
try:
s1 = f"select * from railway where phno='{phno}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
a = ['NAME', 'PHONE NUMBER', 'AGE', 'GENDER', 'STARTING POINT', 'DESTINATION', 'DATE']
for i, val in enumerate(data):
print(f"{a[i]} ::: {val}")
except:
print('TICKET DOES NOT EXIST')
elif ch == 2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def ticket_cancelling():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
print('1.yes')
print('2.no')
ch = int(input("do you want to continue or not:"))
if ch == 1:
phno = input('enter your phone number:')
s1 = f"delete from railway where phno='{phno}'"
cursor.execute(s1)
print('TICKET CANCELLED')
elif ch == 2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def checking_2():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
print('IS THIS YOUR ACCOUNT')
s1 = f"select fname, lname, phno, gender, dob, age from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
x = ['FIRST NAME', 'LAST NAME', 'PHONE NUMBER', 'GENDER', 'DATE OF BIRTH', 'AGE']
for i, val in enumerate(data):
print(f"{x[i]} ::: {val}")
print('1.yes')
print('2.no')
vi = int(input('enter your choice:'))
if vi == 1:
b1 = f"delete from user_accounts where password='{b}'"
cursor.execute(b1)
return True
elif vi == 2:
print('SORRY,RETRY')
else:
print('ERROR 404:PAGE NOT FOUND')
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_1():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
f = input("FIRST NAME:")
l = input("LAST NAME:")
a = input('USER NAME:')
b = input('PASSWORD:')
c = input('RE-ENTER YOUR PASSWORD:')
ph = input("PHONE NUMBER:")
print('M=MALE\nF=FEMALE\nN=NOT TO MENTION')
gen = input('ENTER YOUR GENDER:')
print("ENTER YOUR DATE OF BIRTH")
d = input("DD:")
o = input("MM:")
p = input("YYYY:")
dob = f"{d}/{o}/{p}"
age = input('YOUR AGE:')
v = {'m': 'MALE', 'f': 'FEMALE', 'n': 'NOT TO MENTION'}
if b == c:
try:
c1 = f"insert into user_accounts values('{f}', '{l}', '{a}', '{b}', '{ph}', '{v[gen]}', '{dob}', '{age}')"
cursor.execute(c1)
print('WELCOME', f, l)
return True
except:
print('PASSWORD ALREADY EXISTS')
return False
else:
print('BOTH PASSWORDS ARE NOT MATCHING')
def checking():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
c1 = f"select fname, lname from user_accounts where password='{b}'"
cursor.execute(c1)
data1 = cursor.fetchall()[0]
data1 = f"{data1[0]} {data1[1]}"
print('HII', data1)
return True
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_3():
mycon
= mysql.connector
.connect
(host
='localhost', user
='root', passwd
='root', database
='railway') cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
s1 = f"select fname, lname, phno, gender, dob, age from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
x = ['FIRST NAME', 'LAST NAME', 'PHONE NUMBER', 'GENDER', 'DATE OF BIRTH', 'AGE']
for i, val in enumerate(data):
print(f"{x[i]} ::: {val}")
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()
aW1wb3J0IG15c3FsLmNvbm5lY3RvcgoKbXljb24gPSBteXNxbC5jb25uZWN0b3IuY29ubmVjdChob3N0PSdsb2NhbGhvc3QnLCB1c2VyPSdyb290JywgcGFzc3dkPSdyb290JykKY3Vyc29yID0gbXljb24uY3Vyc29yKCkKbXljb24uYXV0b2NvbW1pdCA9IFRydWUKczEgPSAiY3JlYXRlIGRhdGFiYXNlIHJhaWx3YXkiCmN1cnNvci5leGVjdXRlKHMxKQpzMSA9ICIiImNyZWF0ZSB0YWJsZSByYWlsd2F5KAogICAgbmFtZSB2YXJjaGFyKDEwMCksCiAgICBwaG5vIHZhcmNoYXIoMTUpIHByaW1hcnkga2V5LAogICAgYWdlIGludCg0KSwKICAgIGdlbmRlciB2YXJjaGFyKDUwKSwKICAgIGZyb21fZiB2YXJjaGFyKDEwMCksCiAgICB0b190IHZhcmNoYXIoMTAwKSwKICAgIGRhdGVfZCB2YXJjaGFyKDIwKQopIiIiCmN1cnNvci5leGVjdXRlKHMxKQpzMSA9ICIiImNyZWF0ZSB0YWJsZSB1c2VyX2FjY291bnRzKAogICAgZm5hbWUgdmFyY2hhcigxMDApLAogICAgbG5hbWUgdmFyY2hhcigxMDApLAogICAgdXNlcl9uYW1lIHZhcmNoYXIoMTAwKSwKICAgIHBhc3N3b3JkIHZhcmNoYXIoMTAwKSBwcmltYXJ5IGtleSwKICAgIHBobm8gdmFyY2hhcigxNSksCiAgICBnZW5kZXIgdmFyY2hhcig1MCksCiAgICBkb2IgdmFyY2hhcig1MCksCiAgICBhZ2UgdmFyY2hhcig0KQopIiIiCmN1cnNvci5leGVjdXRlKHMxKQoKZGVmIG1lbnUoKToKICAgIHByaW50KCcxLllFUycpCiAgICBwcmludCgnMi5OTycpCgpjaCA9IGludChpbnB1dCgnRE8gWU9VIFdBTlQgVE8gQ09OVElOVUUgT1IgTk9UOicpKQp3aGlsZSBjaCA9PSAxOgogICAgcHJpbnQoJ1dFTENPTUUgVE8gT05MSU5FIFJBSUxXQVkgUkVTRVJWQVRJT04gU1lTVEVNJykKICAgIHByaW50KCcxLlNJR04gSU4nKQogICAgcHJpbnQoJzIuU0lHTiBVUCcpCiAgICBwcmludCgnMy5ERUxFVEUgQUNDT1VOVCcpCiAgICBwcmludCgnNC5FWElUJykKICAgIGNoMSA9IGludChpbnB1dCgnRU5URVIgWU9VUiBDSE9JQ0U6JykpCiAgICBpZiBjaDEgPT0gMToKICAgICAgICBhID0gY2hlY2tpbmcoKQogICAgICAgIGlmIGE6CiAgICAgICAgICAgIHByaW50KCdXRUxDT01FJykKICAgICAgICAgICAgbWFpbigpCiAgICAgICAgZWxzZToKICAgICAgICAgICAgY29udGludWUKICAgIGVsaWYgY2gxID09IDI6CiAgICAgICAgYSA9IGNoZWNraW5nXzEoKQogICAgICAgIGlmIGE6CiAgICAgICAgICAgIG1haW4oKQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHByaW50KCdQQVNTV09SRCBBTFJFQURZIEVYSVNUUycpCiAgICAgICAgICAgIGNvbnRpbnVlCiAgICBlbGlmIGNoMSA9PSAzOgogICAgICAgIGMgPSBjaGVja2luZ18yKCkKICAgICAgICBpZiBjOgogICAgICAgICAgICBwcmludCgnQUNDT1VOVCBERUxFVEVEJykKICAgICAgICAgICAgY29udGludWUKICAgICAgICBlbHNlOgogICAgICAgICAgICBwcmludCgnWU9VUiBQQVNTV09SRCBPUiBVU0VSX05BTUUgSVMgSU5DT1JSRUNUJykKICAgICAgICAgICAgY29udGludWUKICAgIGVsaWYgY2gxID09IDQ6CiAgICAgICAgcHJpbnQoJ1RIQU5LIFlPVScpCiAgICAgICAgYnJlYWsKICAgIGVsc2U6CiAgICAgICAgcHJpbnQoJ0VSUk9SIDQwNDpQQUdFIE5PVCBGT1VORCcpCiAgICAgICAgYnJlYWsKCmRlZiBtYWluKCk6CiAgICBwcmludCgnMS55ZXMnKQogICAgcHJpbnQoJzIubm8nKQogICAgYyA9IGludChpbnB1dCgiZG8geW91IHdhbnQgdG8gY29udGludWUgb3Igbm90OiIpKQogICAgd2hpbGUgYyA9PSAxOgogICAgICAgIHByaW50KCcnJzEuVElDS0VUIEJPT0tJTkcKMi5USUNLRVQgQ0hFQ0tJTkcKMy5USUNLRVQgQ0FOQ0VMTElORwo0LkFDQ09VTlQgREVUQUlMUwo1LkxPRyBPVVQnJycpCiAgICAgICAgY2ggPSBpbnQoaW5wdXQoJ2VudGVyIHlvdXIgY2hvaWNlOicpKQogICAgICAgIGlmIGNoID09IDE6CiAgICAgICAgICAgIHRpY2tldF9ib29raW5nKCkKICAgICAgICBlbGlmIGNoID09IDI6CiAgICAgICAgICAgIHRpY2tldF9jaGVja2luZygpCiAgICAgICAgZWxpZiBjaCA9PSAzOgogICAgICAgICAgICB0aWNrZXRfY2FuY2VsbGluZygpCiAgICAgICAgZWxpZiBjaCA9PSA0OgogICAgICAgICAgICBjaGVja2luZ18zKCkKICAgICAgICBlbGlmIGNoID09IDU6CiAgICAgICAgICAgIHByaW50KCdUSEFOSyBZT1UnKQogICAgICAgICAgICBicmVhawogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHByaW50KCdFUlJPUiA0MDQ6IEVSUk9SIFBBR0UgTk9UIEZPVU5EJykKCmRlZiB0aWNrZXRfYm9va2luZygpOgogICAgaW1wb3J0IG15c3FsLmNvbm5lY3RvcgogICAgbXljb24gPSBteXNxbC5jb25uZWN0b3IuY29ubmVjdChob3N0PSdsb2NhbGhvc3QnLCB1c2VyPSdyb290JywgcGFzc3dkPSdyb290JywgZGF0YWJhc2U9J3JhaWx3YXknKQogICAgY3Vyc29yID0gbXljb24uY3Vyc29yKCkKICAgIG15Y29uLmF1dG9jb21taXQgPSBUcnVlCiAgICBubSA9IGlucHV0KCdlbnRlciB5b3VyIG5hbWU6JykKICAgIHBobm8gPSBpbnB1dCgnZW50ZXIgeW91ciBwaG9uZSBudW1iZXI6JykKICAgIGFnZSA9IGludChpbnB1dCgnZW50ZXIgeW91ciBhZ2U6JykpCiAgICBwcmludCgnJydNPU1BTEUKRj1GRU1BTEUKTj1OT1QgVE8gTUVOVElPTicnJykKICAgIGdlbmRlciA9IGlucHV0KCdlbnRlciB5b3VyIGdlbmRlcjonKS51cHBlcigpCiAgICBmciA9IGlucHV0KCdlbnRlciB5b3VyIHN0YXJ0aW5nIHBvaW50OicpCiAgICB0byA9IGlucHV0KCdlbnRlciB5b3VyIGRlc3RpbmF0aW9uOicpCiAgICBkYXRlMSA9IGlucHV0KCdlbnRlciBkYXRlKGRkKTonKQogICAgZGF0ZTIgPSBpbnB1dCgnZW50ZXIgbW9udGgobW0pOicpCiAgICBkYXRlMyA9IGlucHV0KCdlbnRlciB5ZWFyKHl5eXkpOicpCiAgICBkYXRlID0gZiJ7ZGF0ZTF9L3tkYXRlMn0ve2RhdGUzfSIKICAgIGEgPSB7J00nOiAnTUFMRScsICdGJzogJ0ZFTUFMRScsICdOJzogJ05PVCBUTyBNRU5USU9OJ30KICAgIHYgPSBhW2dlbmRlcl0KICAgIHMxID0gZiJpbnNlcnQgaW50byByYWlsd2F5IHZhbHVlcyAoJ3tubX0nLCAne3Bobm99Jywge2FnZX0sICd7dn0nLCAne2ZyfScsICd7dG99JywgJ3tkYXRlfScpIgogICAgY3Vyc29yLmV4ZWN1dGUoczEpCiAgICBwcmludCgnQk9PS0VEIFNVQ0NFU1NGVUxMWScpCgpkZWYgdGlja2V0X2NoZWNraW5nKCk6CiAgICBpbXBvcnQgbXlzcWwuY29ubmVjdG9yCiAgICBteWNvbiA9IG15c3FsLmNvbm5lY3Rvci5jb25uZWN0KGhvc3Q9J2xvY2FsaG9zdCcsIHVzZXI9J3Jvb3QnLCBwYXNzd2Q9J3Jvb3QnLCBkYXRhYmFzZT0ncmFpbHdheScpCiAgICBjdXJzb3IgPSBteWNvbi5jdXJzb3IoKQogICAgbXljb24uYXV0b2NvbW1pdCA9IFRydWUKICAgIHByaW50KCcxLnllcycpCiAgICBwcmludCgnMi5ubycpCiAgICBjaCA9IGludChpbnB1dCgiZG8geW91IHdhbnQgdG8gY29udGludWUgb3Igbm90OiIpKQogICAgaWYgY2ggPT0gMToKICAgICAgICBwaG5vID0gaW5wdXQoJ2VudGVyIHlvdXIgcGhvbmUgbnVtYmVyOicpCiAgICAgICAgdHJ5OgogICAgICAgICAgICBzMSA9IGYic2VsZWN0ICogZnJvbSByYWlsd2F5IHdoZXJlIHBobm89J3twaG5vfSciCiAgICAgICAgICAgIGN1cnNvci5leGVjdXRlKHMxKQogICAgICAgICAgICBkYXRhID0gY3Vyc29yLmZldGNoYWxsKClbMF0KICAgICAgICAgICAgYSA9IFsnTkFNRScsICdQSE9ORSBOVU1CRVInLCAnQUdFJywgJ0dFTkRFUicsICdTVEFSVElORyBQT0lOVCcsICdERVNUSU5BVElPTicsICdEQVRFJ10KICAgICAgICAgICAgZm9yIGksIHZhbCBpbiBlbnVtZXJhdGUoZGF0YSk6CiAgICAgICAgICAgICAgICBwcmludChmInthW2ldfSA6Ojoge3ZhbH0iKQogICAgICAgIGV4Y2VwdDoKICAgICAgICAgICAgcHJpbnQoJ1RJQ0tFVCBET0VTIE5PVCBFWElTVCcpCiAgICBlbGlmIGNoID09IDI6CiAgICAgICAgcHJpbnQoJ1RIQU5LIFlPVScpCiAgICBlbHNl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SA9IGlucHV0KCdVU0VSIE5BTUU6JykKICAgIGIgPSBpbnB1dCgnUEFTU1dPUkQ6JykKICAgIHRyeToKICAgICAgICBzMSA9IGYic2VsZWN0IHVzZXJfbmFtZSBmcm9tIHVzZXJfYWNjb3VudHMgd2hlcmUgcGFzc3dvcmQ9J3tifSciCiAgICAgICAgY3Vyc29yLmV4ZWN1dGUoczEpCiAgICAgICAgZGF0YSA9IGN1cnNvci5mZXRjaGFsbCgpWzBdCiAgICAgICAgaWYgZGF0YVswXSA9PSBhOgogICAgICAgICAgICBwcmludCgnSVMgVEhJUyBZT1VSIEFDQ09VTlQnKQogICAgICAgICAgICBzMSA9IGYic2VsZWN0IGZuYW1lLCBsbmFtZSwgcGhubywgZ2VuZGVyLCBkb2IsIGFnZSBmcm9tIHVzZXJfYWNjb3VudHMgd2hlcmUgcGFzc3dvcmQ9J3tifSciCiAgICAgICAgICAgIGN1cnNvci5leGVjdXRlKHMxKQogICAgICAgICAgICBkYXRhID0gY3Vyc29yLmZldGNoYWxsKClbMF0KICAgICAgICAgICAgeCA9IFsnRklSU1QgTkFNRScsICdMQVNUIE5BTUUnLCAnUEhPTkUgTlVNQkVSJywgJ0dFTkRFUicsICdEQVRFIE9GIEJJUlRIJywgJ0FHRSddCiAgICAgICAgICAgIGZvciBpLCB2YWwgaW4gZW51bWVyYXRlKGRhdGEpOgogICAgICAgICAgICAgICAgcHJpbnQoZiJ7eFtpXX0gOjo6IHt2YWx9IikKICAgICAgICAgICAgcHJpbnQoJzEueWVzJykKICAgICAgICAgICAgcHJpbnQoJzIubm8nKQogICAgICAgICAgICB2aSA9IGludChpbnB1dCgnZW50ZXIgeW91ciBjaG9pY2U6JykpCiAgICAgICAgICAgIGlmIHZpID09IDE6CiAgICAgICAgICAgICAgICBiMSA9IGYiZGVsZXRlIGZyb20gdXNlcl9hY2NvdW50cyB3aGVyZSBwYXNzd29yZD0ne2J9JyIKICAgICAgICAgICAgICAgIGN1cnNvci5leGVjdXRlKGIxKQog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iJ7ZH0ve299L3twfSIKICAgIGFnZSA9IGlucHV0KCdZT1VSIEFHRTonKQogICAgdiA9IHsnbSc6ICdNQUxFJywgJ2YnOiAnRkVNQUxFJywgJ24nOiAnTk9UIFRPIE1FTlRJT04nfQogICAgaWYgYiA9PSBjOgogICAgICAgIHRyeToKICAgICAgICAgICAgYzEgPSBmImluc2VydCBpbnRvIHVzZXJfYWNjb3VudHMgdmFsdWVzKCd7Zn0nLCAne2x9JywgJ3thfScsICd7Yn0nLCAne3BofScsICd7dltnZW5dfScsICd7ZG9ifScsICd7YWdlfScpIgogICAgICAgICAgICBjdXJzb3IuZXhlY3V0ZShjMSkKICAgICAgICAgICAgcHJpbnQoJ1dFTENPTUUnLCBmLCBsKQogICAgICAgICAgICByZXR1cm4gVHJ1ZQogICAgICAgIGV4Y2VwdDoKICAgICAgICAgICAgcHJpbnQoJ1BBU1NXT1JEIEFMUkVBRFkgRVhJU1RTJykKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICBlbHNlOgogICAgICAgIHByaW50KCdCT1RIIFBBU1NXT1JEUyBBUkUgTk9UIE1BVENISU5HJykKCmRlZiBjaGVja2luZygpOgogICAgaW1wb3J0IG15c3FsLmNvbm5lY3RvcgogICAgbXljb24gPSBteXNxbC5jb25uZWN0b3IuY29ubmVjdChob3N0PSdsb2NhbGhvc3QnLCB1c2VyPSdyb290JywgcGFzc3dkPSdyb290JywgZGF0YWJhc2U9J3JhaWx3YXknKQogICAgY3Vyc29yID0gbXljb24uY3Vyc29yKCkKICAgIG15Y29uLmF1dG9jb21taXQgPSBUcnVlCiAgICBhID0gaW5wdXQoJ1VTRVIgTkFNRTonKQogICAgYiA9IGlucHV0KCdQQVNTV09SRDonKQogICAgdHJ5OgogICAgICAgIHMxID0gZiJzZWxlY3QgdXNlcl9uYW1lIGZyb20gdXNlcl9hY2NvdW50cyB3aGVyZSBwYXNzd29yZD0ne2J9JyIKICAgICAgICBjdXJzb3IuZXhlY3V0ZShzMSkKICAg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gczEgPSBmInNlbGVjdCBmbmFtZSwgbG5hbWUsIHBobm8sIGdlbmRlciwgZG9iLCBhZ2UgZnJvbSB1c2VyX2FjY291bnRzIHdoZXJlIHBhc3N3b3JkPSd7Yn0nIgogICAgICAgICAgICBjdXJzb3IuZXhlY3V0ZShzMSkKICAgICAgICAgICAgZGF0YSA9IGN1cnNvci5mZXRjaGFsbCgpWzBdCiAgICAgICAgICAgIHggPSBbJ0ZJUlNUIE5BTUUnLCAnTEFTVCBOQU1FJywgJ1BIT05FIE5VTUJFUicsICdHRU5ERVInLCAnREFURSBPRiBCSVJUSCcsICdBR0UnXQogICAgICAgICAgICBmb3IgaSwgdmFsIGluIGVudW1lcmF0ZShkYXRhKToKICAgICAgICAgICAgICAgIHByaW50KGYie3hbaV19IDo6OiB7dmFsfSIpCiAgICAgICAgZWxzZToKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICBleGNlcHQ6CiAgICAgICAgcHJpbnQoJ0FDQ09VTlQgRE9FUyBOT1QgRVhJU1QnKQoKbWVudSgpCg==
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root')
cursor = mycon.cursor()
mycon.autocommit = True
s1 = "create database railway"
cursor.execute(s1)
s1 = """create table railway(
name varchar(100),
phno varchar(15) primary key,
age int(4),
gender varchar(50),
from_f varchar(100),
to_t varchar(100),
date_d varchar(20)
)"""
cursor.execute(s1)
s1 = """create table user_accounts(
fname varchar(100),
lname varchar(100),
user_name varchar(100),
password varchar(100) primary key,
phno varchar(15),
gender varchar(50),
dob varchar(50),
age varchar(4)
)"""
cursor.execute(s1)
def menu():
print('1.YES')
print('2.NO')
ch = int(input('DO YOU WANT TO CONTINUE OR NOT:'))
while ch == 1:
print('WELCOME TO ONLINE RAILWAY RESERVATION SYSTEM')
print('1.SIGN IN')
print('2.SIGN UP')
print('3.DELETE ACCOUNT')
print('4.EXIT')
ch1 = int(input('ENTER YOUR CHOICE:'))
if ch1 == 1:
a = checking()
if a:
print('WELCOME')
main()
else:
continue
elif ch1 == 2:
a = checking_1()
if a:
main()
else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1 == 3:
c = checking_2()
if c:
print('ACCOUNT DELETED')
continue
else:
print('YOUR PASSWORD OR USER_NAME IS INCORRECT')
continue
elif ch1 == 4:
print('THANK YOU')
break
else:
print('ERROR 404:PAGE NOT FOUND')
break
def main():
print('1.yes')
print('2.no')
c = int(input("do you want to continue or not:"))
while c == 1:
print('''1.TICKET BOOKING
2.TICKET CHECKING
3.TICKET CANCELLING
4.ACCOUNT DETAILS
5.LOG OUT''')
ch = int(input('enter your choice:'))
if ch == 1:
ticket_booking()
elif ch == 2:
ticket_checking()
elif ch == 3:
ticket_cancelling()
elif ch == 4:
checking_3()
elif ch == 5:
print('THANK YOU')
break
else:
print('ERROR 404: ERROR PAGE NOT FOUND')
def ticket_booking():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
nm = input('enter your name:')
phno = input('enter your phone number:')
age = int(input('enter your age:'))
print('''M=MALE
F=FEMALE
N=NOT TO MENTION''')
gender = input('enter your gender:').upper()
fr = input('enter your starting point:')
to = input('enter your destination:')
date1 = input('enter date(dd):')
date2 = input('enter month(mm):')
date3 = input('enter year(yyyy):')
date = f"{date1}/{date2}/{date3}"
a = {'M': 'MALE', 'F': 'FEMALE', 'N': 'NOT TO MENTION'}
v = a[gender]
s1 = f"insert into railway values ('{nm}', '{phno}', {age}, '{v}', '{fr}', '{to}', '{date}')"
cursor.execute(s1)
print('BOOKED SUCCESSFULLY')
def ticket_checking():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
print('1.yes')
print('2.no')
ch = int(input("do you want to continue or not:"))
if ch == 1:
phno = input('enter your phone number:')
try:
s1 = f"select * from railway where phno='{phno}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
a = ['NAME', 'PHONE NUMBER', 'AGE', 'GENDER', 'STARTING POINT', 'DESTINATION', 'DATE']
for i, val in enumerate(data):
print(f"{a[i]} ::: {val}")
except:
print('TICKET DOES NOT EXIST')
elif ch == 2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def ticket_cancelling():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
print('1.yes')
print('2.no')
ch = int(input("do you want to continue or not:"))
if ch == 1:
phno = input('enter your phone number:')
s1 = f"delete from railway where phno='{phno}'"
cursor.execute(s1)
print('TICKET CANCELLED')
elif ch == 2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def checking_2():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
print('IS THIS YOUR ACCOUNT')
s1 = f"select fname, lname, phno, gender, dob, age from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
x = ['FIRST NAME', 'LAST NAME', 'PHONE NUMBER', 'GENDER', 'DATE OF BIRTH', 'AGE']
for i, val in enumerate(data):
print(f"{x[i]} ::: {val}")
print('1.yes')
print('2.no')
vi = int(input('enter your choice:'))
if vi == 1:
b1 = f"delete from user_accounts where password='{b}'"
cursor.execute(b1)
return True
elif vi == 2:
print('SORRY,RETRY')
else:
print('ERROR 404:PAGE NOT FOUND')
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_1():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
f = input("FIRST NAME:")
l = input("LAST NAME:")
a = input('USER NAME:')
b = input('PASSWORD:')
c = input('RE-ENTER YOUR PASSWORD:')
ph = input("PHONE NUMBER:")
print('M=MALE\nF=FEMALE\nN=NOT TO MENTION')
gen = input('ENTER YOUR GENDER:')
print("ENTER YOUR DATE OF BIRTH")
d = input("DD:")
o = input("MM:")
p = input("YYYY:")
dob = f"{d}/{o}/{p}"
age = input('YOUR AGE:')
v = {'m': 'MALE', 'f': 'FEMALE', 'n': 'NOT TO MENTION'}
if b == c:
try:
c1 = f"insert into user_accounts values('{f}', '{l}', '{a}', '{b}', '{ph}', '{v[gen]}', '{dob}', '{age}')"
cursor.execute(c1)
print('WELCOME', f, l)
return True
except:
print('PASSWORD ALREADY EXISTS')
return False
else:
print('BOTH PASSWORDS ARE NOT MATCHING')
def checking():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
c1 = f"select fname, lname from user_accounts where password='{b}'"
cursor.execute(c1)
data1 = cursor.fetchall()[0]
data1 = f"{data1[0]} {data1[1]}"
print('HII', data1)
return True
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_3():
import mysql.connector
mycon = mysql.connector.connect(host='localhost', user='root', passwd='root', database='railway')
cursor = mycon.cursor()
mycon.autocommit = True
a = input('USER NAME:')
b = input('PASSWORD:')
try:
s1 = f"select user_name from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
if data[0] == a:
s1 = f"select fname, lname, phno, gender, dob, age from user_accounts where password='{b}'"
cursor.execute(s1)
data = cursor.fetchall()[0]
x = ['FIRST NAME', 'LAST NAME', 'PHONE NUMBER', 'GENDER', 'DATE OF BIRTH', 'AGE']
for i, val in enumerate(data):
print(f"{x[i]} ::: {val}")
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()