-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignUp.py
116 lines (99 loc) · 4.94 KB
/
signUp.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
# checking the password matching condition
import mysql.connector as mysql
from variableValues import host, user, password, database, port, table
from tkinter import Tk, Canvas, Frame, Label, Entry, Button, messagebox
def clickedsignupfree():
if txtfullname.get not in lstfullname:
if not txtfullname.get() == "" and not txtusername.get() == '' and not txtsecuritykey.get() == '' and not txtphoneno.get() == '' and not txtpassword.get() == '' and not txtconfirmpassword.get() == '':
if txtpassword.get() == txtconfirmpassword.get():
if txtusername.get() not in lstusernames:
sql = f'INSERT INTO {table} VALUES ("{txtfullname.get()}", "{txtusername.get()}", "{txtpassword.get()}", "{txtsecuritykey.get()}", {txtphoneno.get()});'
mycur2.execute(sql)
mydb.commit()
messagebox.showinfo(
'Message title', 'Successfully signed up!')
window.destroy()
import login
elif txtusername.get() in lstusernames:
messagebox.showinfo('Sign Up', 'Username already in use')
else:
messagebox.showinfo('Sign Up', 'Passwords do not match')
else:
messagebox.showinfo('Sign Up', 'Fields cannot be left blank')
elif txtfullname.get() in lstfullname:
res = messagebox.askyesno(
'Sign Up', 'Account already exists, want to login?')
if res == 'True':
window.destroy()
import login
# making the introductory window
window = Tk()
window.geometry('600x600')
window.title("Klimacc : One Click to Sustainaibility")
canvas = Canvas(window, height=600, width=600, bg='#fb5b8d')
canvas.pack()
frame1 = Frame(canvas, bg='#000834', bd=10)
frame1.place(relx=0.5, rely=0.06, relwidth=0.8, relheight=0.1, anchor='n')
frame = Frame(canvas, bg='#000834', bd=10)
frame.place(relx=0.5, rely=0.23, relwidth=0.8, relheight=0.6, anchor='n')
# adding the headings for the text boxes
lblloginheading = Label(frame1, text="User Sign Up", font=("Helvetica Bold", 20), anchor="center", bg="#000834",
fg="white")
lblloginheading.place(relx=0.32, rely=0)
lblfullname = Label(frame, text='Full Name', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblfullname.place(relx=0, rely=0.05)
lblusername = Label(frame, text='Username', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblusername.place(relx=0.5, rely=0.05)
lblsecuritykey = Label(frame, text='Provide a Backup Security Key', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblsecuritykey.place(relx=0, rely=0.4)
lblphoneno = Label(frame, text='Phone Number', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblphoneno.place(relx=0.5, rely=0.4)
lblpassword = Label(frame, text='Password', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblpassword.place(relx=0, rely=0.75)
lblconfirmpassword = Label(frame, text='Confirm password', font=(
'Ubuntu Bold', 12), bg="#000834", fg="white")
lblconfirmpassword.place(relx=0.5, rely=0.75)
# adding the textboxes
txtfullname = Entry(frame)
txtfullname.place(relx=0.03, rely=0.15, relwidth=0.45, relheight=0.08)
txtusername = Entry(frame)
txtusername.place(relx=0.53, rely=0.15, relwidth=0.45, relheight=0.08)
txtsecuritykey = Entry(frame)
txtsecuritykey.place(relx=0.03, rely=0.5, relwidth=0.45, relheight=0.08)
txtphoneno = Entry(frame)
txtphoneno.place(relx=0.53, rely=0.5, relwidth=0.45, relheight=0.08)
txtpassword = Entry(frame)
txtpassword.place(relx=0.03, rely=0.85, relwidth=0.45, relheight=0.08)
txtconfirmpassword = Entry(frame)
txtconfirmpassword.place(relx=0.53, rely=0.85, relwidth=0.45, relheight=0.08)
# creating lists for checking conditions in password check
lstusernamesandpasswords = []
# connecting to mysql
mydb = mysql.connect(
host=host, user=user, password=password, database=database, port=port)
mycursor = mydb.cursor()
# creating table using the existing condition
mycur2 = mydb.cursor(buffered=True)
mycur2.execute(
f"CREATE TABLE IF NOT EXISTS {table} (Name Varchar(50), Username Varchar(50), Password Varchar(50), SecurityKey Varchar(20), Phoneno Numeric(13));")
mydb.commit()
# getting the records of the registered users
mycursor.execute(f"SELECT * FROM {table}")
myresult = mycursor.fetchall()
for x in myresult:
lstusernamesandpasswords.append(list(x))
# making a separate list of usernames,passwords,securitykeys,and phonenos
lstusernames = []
lstfullname = []
for i in range(len(lstusernamesandpasswords)):
lstusernames.append(lstusernamesandpasswords[i][1])
lstfullname.append(lstusernamesandpasswords[i][0])
btnsignupfree = Button(canvas, text="Sign Up", font=(
'Ubuntu Bold', 13), fg="white", bg='#000834', command=clickedsignupfree)
btnsignupfree.place(relx=0.38, rely=0.88, relheight=0.05, relwidth=0.25)
window.mainloop()