Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- def sign_up():
- username = input("Enter username: ")
- password = input("Enter password: ")
- first_name = input("Enter first name: ")
- last_name = input("Enter last name: ")
- connection = sqlite3.connect('userinfo.db')
- c = connection.cursor()
- c.execute("""INSERT INTO UserInfo VALUES ('%s', '%s', '%s', '%s')""" % (username, password, first_name, last_name))
- connection.commit()
- connection.close()
- def reset_password(username):
- user = username
- new_pass = input("Enter new password: ")
- connection = sqlite3.connect('userinfo.db')
- c = connection.cursor()
- c.execute("""SELECT * FROM UserInfo""")
- table = c.fetchall()
- for row in table:
- if user in row:
- c.execute("""UPDATE UserInfo SET Password='%s' WHERE Username='%s'""" % (new_pass, user))
- print("Success!")
- connection.commit()
- connection.close()
- def login_menu(name):
- while True:
- print("\nHello, %s" % (name))
- print("Select an option: ")
- print("1. Reset Password")
- print("2. Exit")
- choice = int(input("= "))
- if choice == 1:
- username = input("Enter username: ")
- reset_password(username)
- elif choice == 2:
- print("Goodbye!")
- return False
- else:
- print("You did not select one!")
- def login():
- flag = False
- name = ""
- while flag == False:
- username = input("\nEnter Username: ")
- password = input("Enter Password: ")
- connection = sqlite3.connect('userinfo.db')
- c = connection.cursor()
- c.execute("""SELECT Username,Password,First_Name FROM UserInfo""")
- table = c.fetchall()
- for row in table:
- if username in row:
- if row[1] == password:
- name = row[2]
- flag = True
- else:
- print("Incorrect password!")
- login_menu(name)
- def menu():
- print("Welcome!")
- print("Select an option via the number!\n")
- print("1. Signup")
- print("2. Login")
- choice = int(input("= "))
- if choice == 1:
- sign_up()
- elif choice == 2:
- login()
- else:
- print("You did not select one!")
- menu()
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement