forked from jatin-mawa7/UPSERVE-SYSTEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.py
165 lines (114 loc) · 4.15 KB
/
registration.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 ast
import pymysql
window=Tk()
window.title("Registration Form")
window.geometry('925x500+300+200')
window.configure(bg='#282633')
window.resizable(False,False)
def clear():
user.delete(0,END)
email.delete(0,END)
addr.delete(0, END)
phno.delete(0, END)
aphno.delete(0, END)
user.insert(0, 'Name')
email.insert(0, 'Email ID')
addr.insert(0, 'Address')
phno.insert(0, 'Phone Number')
aphno.insert(0, 'Alternate Contact Details')
def register():
try:
if user.get()=='Name' or email.get()=='Email ID' or addr.get()=='Address' or phno.get()=='Phone Number' or \
aphno.get()=='Alternate Contact Details':
messagebox.showerror('Error','All Fields Are Required')
else:
con=pymysql.connect(host='localhost',user='root',password='Root@1234',database='upserve')
cur=con.cursor()
cur.execute('select * from customers where email=%s',email.get())
row=cur.fetchone()
if row!=None:
messagebox.showerror('Error','User Already Exists')
else:
cur.execute('insert into customers(name,email,address,contact_no,alt_contact_details) values(%s,%s,%s,%s,%s)',
(user.get(),email.get(),addr.get(),phno.get(),aphno.get()))
con.commit()
con.close()
messagebox.showinfo('Success','Registration Successful')
clear()
except Exception as e:
messagebox.showerror('Error',f'Error due to{e}')
img= PhotoImage(file="img.png")
Label(window,image=img,border=0,bg='#282633').place(x=10,y=90)
frame=Frame(window,width=350,height=390,bg='#282633')
frame.place(x=480,y=50)
heading=Label(frame,text='Registration Form',fg="#57a1f8",bg='#282633',font=('Microsoft Yahei UI Light',23,'bold'))
heading.place(x=20,y=5)
#####---------------------
def on_enter(e):
user.delete(0,'end')
def on_leave(e):
if user.get()=='':
user.insert(0,'Name')
user = Entry(frame,width=25,fg='white',border=0,bg='#282633',font=('Microsoft Yahei UI Light',11))
user.place(x=30,y=80)
user.insert(0,'Name')
user.bind("<FocusIn>",on_enter)
user.bind("<FocusOut>",on_leave)
Frame(frame,width=295,height=2,bg='white').place(x=25,y=107)
#####---------------------
def on_enter(e):
email.delete(0,'end')
def on_leave(e):
if email.get()=='':
email.insert(0,'Email ID')
email = Entry(frame,width=25,fg='white',border=0,bg='#282633',font=('Microsoft Yahei UI Light',11))
email.place(x=30,y=130)
email.insert(0,'Email ID')
email.bind("<FocusIn>",on_enter)
email.bind("<FocusOut>",on_leave)
Frame(frame,width=295,height=2,bg='white').place(x=25,y=157)
#####---------------------
def on_enter(e):
addr.delete(0,'end')
def on_leave(e):
if addr.get()=='':
addr.insert(0,'Address')
addr = Entry(frame,width=25,fg='white',border=0,bg='#282633',font=('Microsoft Yahei UI Light',11))
addr.place(x=30,y=180)
addr.insert(0,'Address')
addr.bind("<FocusIn>",on_enter)
addr.bind("<FocusOut>",on_leave)
Frame(frame,width=295,height=2,bg='white').place(x=25,y=207)
#####---------------------
def on_enter(e):
phno.delete(0,'end')
def on_leave(e):
if phno.get()=='':
phno.insert(0,'Phone Number')
phno = Entry(frame,width=25,fg='white',border=0,bg='#282633',font=('Microsoft Yahei UI Light',11))
phno.place(x=30,y=230)
phno.insert(0,'Phone Number')
phno.bind("<FocusIn>",on_enter)
phno.bind("<FocusOut>",on_leave)
Frame(frame,width=295,height=2,bg='white').place(x=25,y=257)
#####---------------------
def on_enter(e):
aphno.delete(0,'end')
def on_leave(e):
if aphno.get()=='':
aphno.insert(0,'Alternate Contact Details')
aphno = Entry(frame,width=25,fg='white',border=0,bg='#282633',font=('Microsoft Yahei UI Light',11))
aphno.place(x=30,y=280)
aphno.insert(0,'Alternate Contact Details')
aphno.bind("<FocusIn>",on_enter)
aphno.bind("<FocusOut>",on_leave)
Frame(frame,width=295,height=2,bg='white').place(x=25,y=307)
#----------------
Button(frame,width=39,pady=7,text='Register',bg='#57a1f8',fg='#282633',border=0,cursor='hand2',command=register).place(x=35,y=350)
'''label=Label(frame,text='I have an account',fg='white',bg='#282633',font=('Microsoft Yahei UI Light',9))
label.place(x=90,y=340)
signin=Button(frame,width=6,text='Sign In',border=0, bg='#282633',cursor='hand2',fg='#57a1f8')
signin.place(x=200,y=342)'''
window.mainloop()