-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
136 lines (104 loc) · 4.43 KB
/
admin.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
from tkinter import *
from tkinter import messagebox
import mysql.connector
background="#06283D"
framebg="#EDEDED"
framefg="#06283d"
root=Tk()
root.title("New User Registration")
root.geometry("1250x700+210+100")
root.config(bg=background)
root.resizable(False,False)
def register():
username = user.get()
password = code.get()
admincode=adminaccess.get()
print(username,password,admincode) # checking to confirm once
if admincode=="032842":
if (username=="" or user =="UserID") or (password=="" or password=="Password"):
messagebox.showerror("Entry Error!","Type User name or Password")
else:
try:
mydb=mysql.connector.connect(host='localhost',user='root',password='0328')
mycursor=mydb.cursor()
print("Connection Established!!")
except:
messagebox.showerror("Connection error","Database Connection not established!")
try:
command="create database StudentRegistration"
mycursor.execute(command)
command="use StudentRegistration"
mycursor.execute(command)
command="create table login (user int auto_increment key not null,username varchar(100),password varchar(100));"
mycursor.execute(command)
except:
mycursor.execute("use StudentRegistration")
mydb=mysql.connector.connect(host='localhost',user='root',password='0328',database="StudentRegistration")
mycursor=mydb.cursor()
command="insert into login(username,password) values(%s,%s)"
mycursor.execute(command,(username,password))
mydb.commit()
messagebox.showinfo("Admin","New User added Successfully!!")
else:
messagebox.showerror("Admin code ","Input Correct Admin code to add new user")
def login():
root.destroy()
import login
def user_enter(e):
user.delete(0,'end')
def user_leave(e):
name=user.get()
if name=='':
user.insert(0,"UserID")
def password_enter(e):
code.delete(0,'end')
def password_leave(e):
if code.get()=='':
code.insert(0,"Password")
#icon
image_icon=PhotoImage(file="Images1/icon.png")
root.iconphoto(False,image_icon)
# root.iconname("ADMIN")
# background#######################################################################
frame=Frame(root,bg="red")
frame.pack(fill=Y)
backgroundimage=PhotoImage(file="Images1/register.png")
Label(frame,image=backgroundimage).pack()
adminaccess=Entry(frame,width=15,fg="#000",border=0,bg="#e8ecf7",font=("Arial",20,"bold"),show="*")
adminaccess.focus()
adminaccess.place(x=550,y=280)
# user entry############################################################
user=Entry(root,width=10,fg="#fff",bg="#375174",border=0,font=("Arial",20,"bold"))
user.insert(0,"UserID")
user.bind("<FocusIn>",user_enter)
user.bind("<FocusOut>",user_leave)
user.place(x=500,y=380)
# pass entry########################################
code=Entry(root,width=10,fg="#fff",bg="#375174",border=0,font=("Arial",20,"bold"))
code.insert(0,"Password")
code.bind("<FocusIn>",password_enter)
code.bind("<FocusOut>",password_leave)
code.place(x=500,y=470)
# button mode########################################
button_mode=True
def hide():
global button_mode
if button_mode:
eyeButton.config(image=closeeye,activebackground="white")
code.config(show="*")
button_mode=False
else:
eyeButton.config(image=openeye,activebackground="white")
code.config(show="")
button_mode=True
openeye=PhotoImage(file="Images1/openeye.png")
closeeye=PhotoImage(file="Images1/close eye.png")
eyeButton=Button(frame,image=openeye,bg="#375174",bd=0,command=hide)
eyeButton.place(x=780,y=470)
##########################################################3
regis_button=Button(root,text="ADD NEW USER",bg="#455c88",fg="white",width=13,height=1,font=("Arial",16,"bold"),bd=0,command=register)
regis_button.place(x=530,y=600)
backbuttonimage=PhotoImage(file="Images1/backbutton.png")
backbutton=Button(root,image=backbuttonimage,fg="#deeefb",command=login)
backbutton.place(x=20,y=15)
root.mainloop()