first commit

main
Zeng Jia Hua 6 months ago
parent ae88460d3a
commit d7e4b7b55f

@ -1,25 +1,23 @@
from tkinter import *
import Home
from login_check import check
user_login={'aaa':'123456','bbb':'888888','ccc':'333333'}
count=0
def login():
global count
username=entry_username.get()
if username not in user_login:
lable_message.config(text="账号错误!")
username = entry_username.get()
password = entry_password.get()
if check(username,password):
lable_message.config(text="登陆成功!")
window.destroy()
h = Home.Home()
else:
password=entry_password.get()
if(password==user_login[username]):
lable_message.config(text="登陆成功!")
window.destroy()
h=Home.Home()
else:
lable_message.config(text="你还可以尝试{}".format(2-count))
count+=1
if count==3:
lable_message.config(text="登陆失败!")
btn_login.config(state='disabled')
lable_message.config(text="你还可以尝试{}".format(2-count))
count+=1
if count==3:
lable_message.config(text="登陆失败!")
btn_login.config(state='disabled')
window = Tk()
window.title('用户登陆')
window.geometry("300x200")

@ -0,0 +1,20 @@
import mysql.connector
def check(id,psw):
db=mysql.connector.connect(
host='localhost',
user='root',
passwd='123456',
database='loopy'
)
cursor=db.cursor()
sql='select * from user where id = %s and password = %s'
cursor.execute(sql,(id,psw))
result=cursor.fetchall()
for row in result:
if id==row[0] and psw==row[1]:
return True
else:
return False
Loading…
Cancel
Save