Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- class Tinder:
- def __init__(self):
- self.conn = mysql.connector.connect(user="root",password="password",host="localhost",database="tinder")
- self.mycursor=self.conn.cursor()
- self.program_menu()
- def program_menu(self):
- print("\n\n\tWELCOME TO TINDER\n\n")
- print("""\n Enter 1 to login \n Enter 2 to Register \n Enter 3 to exit""")
- choice=int(input("Enter your choice:\t"))
- if choice == 1:
- self.user_login()
- elif choice == 2:
- self.user_register()
- elif choice == 3:
- print("THANK YOU! BYE!")
- else:
- print("Invalid Input. Try again!")
- self.program_menu()
- def user_register(self):
- name=input("Enter your name:\t")
- email=input("Enter your email:\t")
- password=input("Enter your password:\t")
- gender=input("Enter your gender:\t")
- city=input("Enter your city:\t")
- self.mycursor.execute("""
- INSERT INTO `users`
- (`name`,`email`,`password`,`gender`,`city`)
- VALUES('%s','%s','%s','%s','%s')
- """ %(name,email,password,gender,city))
- self.conn.commit()
- self.program_menu()
- def user_login(self):
- email=input("Enter your email:\t")
- password=input("Enter your password:\t")
- self.mycursor.execute("""
- SELECT * from `users` WHERE
- `email` LIKE '%s' and `password` LIKE '%s'
- """ %(email,password))
- user_list = self.mycursor.fetchall()
- c=0
- for i in user_list:
- c=c+1
- self.current_user_id=i[0]
- if c==1:
- self.user_menu()
- else:
- print("Invalid Credentials")
- self.program_menu()
- def user_menu(self):
- print("Success!!")
- ob1=Tinder()
Add Comment
Please, Sign In to add comment