daily pastebin goal
65%
SHARE
TWEET

loginApplicationProblem

a guest Nov 6th, 2018 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sqlite3
  2. status= ""
  3. def displayMenu():
  4.     status= input("Are you a registered user? y/n? Press q to quit: ")
  5.     if status.lower()== "y":
  6.         currentUser()
  7.     elif status.lower()=="n":
  8.         newUser()
  9.  
  10. def currentUser():
  11.     conn= sqlite3.connect('OS_Employee.db')
  12.     userEmail= input("Enter login name: ")
  13.     password= input("Enter password: ")
  14.     with conn:
  15.         cur= conn.cursor()
  16.         try:
  17.             cur.execute("SELECT*FROM employee WHERE(email='"+ userEmail + "'AND password= '"+ password+"')")
  18.             results= cur.fetchall()
  19.             rowCounter=0
  20.             for row in results:
  21.                 rowCounter+=1
  22.             if results:
  23.                 for i in results:
  24.                     print("Login successful")
  25.                     loginSuccess = True
  26.             else:
  27.                 print("Login unsucessful")
  28.                
  29.         except:
  30.              print("Connection failed")
  31.                
  32. def newUser():
  33.     try:
  34.         createID= int(input("Enter employee ID: "))
  35.     except ValueError:
  36.         print("\nenter a valid employee ID\n")
  37.     with sqlite3.connect('OS_Employee.db') as db:
  38.         user= db.cursor()
  39.     if createID in user:
  40.         print("ID already exists")
  41.     else:
  42.         createLogin= input("Enter your email: ")
  43.         if createLogin in user:
  44.             print("email already exist")
  45.         else:
  46.             createPass= input("Enter new password: ")
  47.             user[createLogin]= createPass
  48.             print("\nNew user create\n")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top