未在python中保存和验证数据库登录
我正在做一个程序,我需要做一个系统登录保存在数据库中 程序未在数据库中保存和验证用户。有人能帮我理解我哪里出了错吗 我还是一个初级程序员 多谢各位未在python中保存和验证数据库登录,python,database,authentication,save,verification,Python,Database,Authentication,Save,Verification,我正在做一个程序,我需要做一个系统登录保存在数据库中 程序未在数据库中保存和验证用户。有人能帮我理解我哪里出了错吗 我还是一个初级程序员 多谢各位 def login(): global screen1 screen1 = Toplevel(screen) screen1.title("Login!") screen1.geometry("300x250") global username global password global username_entry
def login():
global screen1
screen1 = Toplevel(screen)
screen1.title("Login!")
screen1.geometry("300x250")
global username
global password
global username_entry
global password_entry
username = StringVar()
password = StringVar()
Label(screen1, text = "Ensira os seus dados nos campos abaixo!").pack()
Label(screen1, text = "").pack()
Label(screen1, text = "Utilizador * ").pack()
username_entry = Entry(screen1, textvariable = username)
username_entry.pack()
Label(screen1, text = "Password * ").pack()
password_entry = Entry(screen1, textvariable = password)
password_entry.pack()
Label(screen1, text = "").pack()
Button(screen1, text = "Entrar.", width = 10, height = 1, command = VerificarLogin).pack()
#Função para receber a password e criptografa-la para comparar
def VerificarLogin():
password = password_entry.get()
encodedBytes = base64.b64encode(password.encode("utf-8"))
passEncry = str(encodedBytes, "utf-8")
cursor.execute("UPDATE user SET Online = '0' WHERE nome = 'admin' ")
ConnectBD.connection.commit()
cursor.execute("UPDATE user SET Online = '0' WHERE nome = 'Angelo' ")
ConnectBD.connection.commit()
cursor.execute("UPDATE user SET Online = '0' WHERE nome = 'Henrique' ")
ConnectBD.connection.commit()
if password.get() == "admin" and passEncry == username[0][2]:
cursor.execute("UPDATE user SET Online = '1' WHERE nome = 'admin' ")
ConnectBD.connection.commit()
for x in range(len(username)):
if password.get() == username[x][1] and passEncry == username[x][2]:
cursor.execute("UPDATE user SET Online = '1' WHERE nome = '%s' "%(username[x][1]) )
ConnectBD.connection.commit()
你能说得更具体些吗?你做过任何调试吗?这是登录到其他程序。当用户登录程序时,他们可以更改数据库。不,我什么都不做请你的问题来澄清你的具体问题或添加额外的细节来突出你需要什么。正如目前所写的,很难准确地说出你在问什么。请参阅本页以获取澄清此问题的帮助。您能更具体地说明吗?你做过任何调试吗?这是登录到其他程序。当用户登录程序时,他们可以更改数据库。不,我什么都不做请你的问题来澄清你的具体问题或添加额外的细节来突出你需要什么。正如目前所写的,很难准确地说出你在问什么。请参阅页面以获取澄清此问题的帮助。