connection = sqlite3.connect("login_register_system/user_db")
c = connection.cursor()
c.execute("""CREATE TABLE IF NOT EXISTS users (
ID text,
Firstname text,
Lastname text,
Email text,
Password text)""")
def login_authenticator():
e = (emailE.get())
p = (passwordE.get())
c.execute(f"""SELECT * FROM users WHERE Email=? AND Password=?""", (e, p))
if e == p in "user_db":
print("User exists")
else:
print("User does not exist")
This is just a part of the whole program I am trying to create, I want to know how I can check to see if a user email and password in the same row match, if they do, I can then create an IF statement to create a log in. I am not sure if I'm on the right track.
CodePudding user response:
More like this:
def login_authenticator():
e = emailE.get()
p = passwordE.get()
q = c.execute("SELECT * FROM users WHERE Email=? AND Password=?", (e, p))
if q.fetchone():
print("User exists and password matches")
else:
print("User does not exist or password does not match")
I assume you understand it's a hugely bad idea to store and transmit passwords in the clear like that.
One also might ask why you're using print in a tkinter application, but I assume you'll get to that.
