0
我在尝试验证凭据时遇到问题(我将发布以下代码)。我想知道是否发生这种情况,因为我在数据库中存储了用户名和密码作为字符串,是否应该将其存储为整数?Python3,Tkinter,SQLite3 - 登录编码错误
问题:我认为简单举一个问题的例子比较容易,也许它更容易理解。
信息是正确的(用户名=东西和密码=测试)
示例1:您输入“东西”作为用户名和“密码”的密码 - 这很好它的工作原理,但是下一个例子是那里的东西出错。
示例2:输入用户名“somethingfpsadadoia”和密码“testing” - 只要密码正确,程序就会说它是正确的。所以只要你有用户名下的部分用户名,那么密码就可以工作,但是之后的任何内容都不会被认为是错误的。
非常感谢,如果有人能帮助!
“” “ 高清Is_Valid():
UsernameValidity=UserName_Entry.get()
PasswordValidity=Password_Entry.get()
cursor.execute('''SELECT password FROM users WHERE username = ?''', (UsernameValidity,))
cursor.execute('''SELECT username FROM users WHERE password = ?''', (PasswordValidity,))
LogInAttempt = cursor.fetchone()
print (Is_Valid) # Testing to see if it works on shell
if LogInAttempt:
print (" One of the accounts have successfully logged in ")
IsValidText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
myGUI.after(1000, CoreContent) # Ignore this one for now.
else:
print (" One of the accounts inputted the wrong credentials! ")
IsValidText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
”“”
太谢谢你了! – sago