Jun-24-2022, 01:50 PM
(Jun-11-2022, 12:48 AM)menator01 Wrote: Add privilege to your select statement then show the correct menu occordding to the returned result.
Ok, I got that part.
(This is what I have)
#---------------------------------- import sqlite3 connection = sqlite3.connect("users.db") cursor = connection.cursor() # cursor.execute(''' # insert into Users (Name, Password, Privilege) # values ('Admin',1234,'admins') # ''') cursor.execute("SELECT*FROM Users") print(cursor.fetchall()) cursor.execute(f"SELECT Privilege from Users WHERE Name ='{userInputName}' AND Password = '{userInputPassword}';") connection.commit() privilege = cursor.fetchone() print("Result: ",privilege) if privilege == "admins": print("Hello admin User") elif privilege == "user": print("Hello standard user") else: print("Try again") #Close the connection connection.close() #----------------------------------This is what it outputs if I type in Name:Bob, & Password:1234:
Output:[(1, 'Admin', 1234, 'admins'), (2, 'Admin', 1234, 'admins'), (3, 'Bob', 1234, 'user')]
Result: ('user',)
Try again
Why doesn't it print("Hello standard user")?Thanks in advance.