Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import time
- from pymysql import cursors
- import pymysql
- #####
- lWindow = Tk()
- lWindow.geometry("210x175")
- ###############
- def lClick():
- __uID = uID.get()
- __uName = uName.get()
- __passW = passW.get()
- print(__uName)
- print(__passW)
- auth = Label(lWindow, text="Authorizing...",font=("Areial Bold", 10))
- auth.place(x=-10,y=99)
- time.sleep(0.5)
- time.sleep(1)
- def authorize():
- if __uID == "01":
- auth.configure(text='''
- User Authenticated...
- Accessing Database
- ''')
- ##############################################################
- def dbCon():
- con = pymysql.connect(host='192.***.***.**',
- user='****',
- password='*****',
- db='python1',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- with con:
- cur = con.cursor()
- cur.execute("SELECT * FROM users WHERE 'id' = '{0}'".format(__uID))
- rows = cur.fetchall()
- for row in rows:
- db_username = row['username']
- db_password = row['password']
- def logon():
- if __uName == db_username:
- auth.configure(text="DataBase Connected")
- else:
- auth.configure(text="Error Has Occured")
- logon()
- dbCon()
- else:
- auth.configure(text="Not Authorized")
- authorize()
- ##############################################################
- ###############
- uIDLbl = Label(lWindow, text="User ID:")
- uIDLbl.place(x=5,y=5)
- uID = Entry(lWindow)
- uID.place(x=70,y=5)
- uNameLbl = Label(lWindow, text="Username:")
- uNameLbl.place(x=5,y=27)
- uName = Entry(lWindow)
- uName.place(x=70,y=27)
- passWLbl = Label(lWindow, text="Password:")
- passWLbl.place(x=5,y=50)
- passW = Entry(lWindow, show="*")
- passW.place(x=70,y=50)
- lBtn = Button(lWindow, text="Login", command=lClick)
- lBtn.place(x=50,y=72, width=100)
- #################
- lWindow.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement