-
Notifications
You must be signed in to change notification settings - Fork 1
/
Database_LogIn.py
164 lines (135 loc) · 5.25 KB
/
Database_LogIn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from tkinter import *
from tkinter import messagebox
import mysql.connector
import os
import time
#importing the code files
#connecting to the database
db = mysql.connector.connect(host="localhost",user="root",passwd="Vishal123",database="project_dbms")
mycur = db.cursor()
def error_destroy():
err.destroy()
def succ_destroy():
succ.destroy()
root1.destroy()
def error():
global err
err = Toplevel(root1)
err.title("Error")
err.geometry("200x100")
Label(err,text="All fields are required..",fg="red",font="bold").pack()
Label(err,text="").pack()
Button(err,text="Ok",bg="grey",width=8,height=1,command=error_destroy).pack()
def success():
global succ
succ = Toplevel(root1)
succ.title("Success")
succ.geometry("250x100")
Label(succ, text="Registration successful...", fg="green", font="bold").pack()
Label(succ, text="").pack()
Button(succ, text="Ok", bg="grey", width=8, height=1, command=succ_destroy).pack()
def register_user():
username_info = username.get()
password_info = password.get()
if username_info == "":
error()
elif password_info == "":
error()
else:
sql = "insert into login values(%s,%s)"
t = (username_info, password_info)
mycur.execute(sql, t)
db.commit()
Label(root1, text="").pack()
time.sleep(0.50)
success()
def registration():
global root1
root1 = Toplevel(root)
root1.title("Registration Portal")
root1.geometry("300x250")
global username
global password
Label(root1,text="Register your account",bg="grey",fg="black",font="bold",width=300).pack()
username = StringVar()
password = StringVar()
Label(root1,text="").pack()
Label(root1,text="Username :",font="bold").pack()
Entry(root1,textvariable=username).pack()
Label(root1, text="").pack()
Label(root1, text="Password :").pack()
Entry(root1, textvariable=password,show="*").pack()
Label(root1, text="").pack()
Button(root1,text="Register",bg="green",command=register_user).pack()
def login():
global root2
root2 = Toplevel(root)
root2.title("Log-In Portal")
root2.geometry("300x300")
global username_varify
global password_varify
Label(root2, text="Log-In Portal", bg="grey", fg="black", font="bold",width=300).pack()
username_varify = StringVar()
password_varify = StringVar()
Label(root2, text="").pack()
Label(root2, text="Username :", font="bold").pack()
Entry(root2, textvariable=username_varify).pack()
Label(root2, text="").pack()
Label(root2, text="Password :").pack()
Entry(root2, textvariable=password_varify, show="*").pack()
Label(root2, text="").pack()
Button(root2, text="Log-In", bg="green",command=login_varify).pack()
Label(root2, text="")
def logg_destroy():
logg.destroy()
root2.destroy()
def fail_destroy():
fail.destroy()
def logged():
global logg
logg = Toplevel(root2)
logg.title("Welcome")
logg.geometry("800x300")
Label(logg, text="Welcome {}! ".format(username_varify.get()), fg="Blue", font="bold").pack()
Label(logg, text="{} And Now You can acess this bank management system ".format(username_varify.get()), fg="green", font="bold").pack()
Label(logg, text=" Now {}, You have to close all the windows ".format(username_varify.get()), fg="red", font="bold").pack()
Label(logg, text=" Then {}, You can automatically reach to the Landing Page ".format(username_varify.get()), fg="brown", font="bold").pack()
Label(logg, text=" As you can closes all the windows".format(username_varify.get()), fg="brown", font="bold").pack()
Label(logg, text="Thank u".format(username_varify.get()), fg="blue", font="bold").pack()
Button(logg, text="Log-Out", bg="grey", width=8, height=1, command=logg_destroy).pack()
def failed():
global fail
fail = Toplevel(root2)
fail.title("Invalid")
fail.geometry("200x100")
Label(fail, text="Invalid credentials...", fg="red", font="bold").pack()
Label(fail, text="").pack()
Button(fail, text="Ok", bg="grey", width=8, height=1, command=fail_destroy).pack()
def login_varify():
user_varify = username_varify.get()
pas_varify = password_varify.get()
sql = "select * from login where u_name = %s and password = %s"
mycur.execute(sql,[(user_varify),(pas_varify)])
results = mycur.fetchall()
if results:
for i in results:
logged()
break
else:
failed()
def main_screen():
global root
root = Tk()
root.title("Log-IN Portal")
root.geometry("300x300")
Label(root,text="Welcome to Group9",font="bold",bg="grey",fg="black",width=300).pack()
Label(root,text="").pack()
Button(root,text="Log-IN",width="8",height="1",bg="green",font="bold",command=login).pack()
Label(root,text="").pack()
Button(root, text="Registration",height="1",width="15",bg="green",font="bold",command=registration).pack()
Label(root,text="").pack()
Label(root,text="").pack()
Label(root,text="Developed By Group9").pack()
main_screen()
# import LandingPage as lp
root.mainloop()