-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.py
88 lines (67 loc) · 3.07 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
# Importing the Libraries
from tkinter import *
import tkinter.messagebox
import sqlite3
# Importing other modules
import home
import login
def signUp():
signUp = Tk()
signUp.geometry("1024x786")
signUp.resizable(0,0)
signUp.title("MovieZone - Movie Ticket Booking")
bgColor1 = "#C7EFCF"; bgColor3= "#FE5F55"
fgColor1 = "#EEF5DB"
banner = LabelFrame(signUp, width=1024, height=785, bg=bgColor1, padx=70, pady=20)
banner.place(x=0, y=0)
box1 = LabelFrame(signUp, width=500, height=80, bg=bgColor3)
box1.place(x=300, y=100)
label1 = Label(box1, text="SIGN UP", font=('Cambria', 26, 'bold'), fg=fgColor1, bg=bgColor3)
label1.place(x=180, y=20)
box2 = LabelFrame(signUp, width=500, height=480, bg=fgColor1)
box2.place(x=300, y=180)
Label(box2, text="Username", font=('comic', 12), fg=bgColor3).place(x=70, y=30)
entry1 = Entry(box2, width=40, bd=3)
entry1.place(x=70, y=55)
Label(box2, text="Password", font=('comic', 12), fg=bgColor3).place(x=70, y=120)
entry2 = Entry(box2, width=40, bd=3)
entry2.place(x=70, y=145)
Label(box2, text="Email", font=('comic', 12), fg=bgColor3).place(x=70, y=210)
entry3 = Entry(box2, width=40, bd=3)
entry3.place(x=70, y=235)
Label(box2, text="Age", font=('comic', 12), fg=bgColor3).place(x=70,y=290)
entry4 = Entry(box2, width=10, bd=3)
entry4.place(x=70, y=315)
# Function to insert new entries in the database
def insert(entry1, entry2, entry3, entry4):
# Extract the user-entered values in the following fields
username = entry1.get()
password = entry2.get()
email = entry3.get()
age = entry4.get()
# If any of the field is blank, prompt an error to the user
if username=="":
messagebox.showerror("Movie-Zone", "Username cannot be blank")
elif password=="":
messagebox.showerror("Movie-Zone", "Password cannot be blank")
elif email=="":
messagebox.showerror("Movie-Zone", "Email cannot be blank")
elif age=="":
messagebox.showerror("Movie-Zone", "Age cannot be blank")
else:
# Else if all the details are entered, connect to the database
connection = sqlite3.connect('assets/movieTicket.db')
cur = connection.cursor()
# SQL Statement to insert/add new entries in the table `user`
cur.execute('''INSERT into user (username, password, email, age)
VALUES (?, ?, ?, ?)''', (username, password, email, age))
# Commit the chnages and close the connection
cur.close()
connection.commit()
connection.close()
# Redirect to the login interface
createNew(signUp, login.logIn)
signUpB = Button(box2, text="Create Account", width=15, bg=bgColor3, fg=fgColor1, font=('cambria', 14),
command=lambda: insert(entry1, entry2, entry3, entry4))
signUpB.place(x=160, y=380)
signUp.mainloop()