0% found this document useful (0 votes)
10 views26 pages

Group 7

Uploaded by

marivic mallari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views26 pages

Group 7

Uploaded by

marivic mallari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

z

CSS
z

 Import tkinter as tk

 from tkinter import messagebox, simpledialog

 accounts = {}

 def set_focus():

 username_entry.focus_set()
z
z

 Def create_account():

 username = username_entry.get()

 password = password_entry.get()

 if username in accounts:

 messagebox.showerror(“Account Creation Failed”, “Username already exists.”)

 elif username == “” or password == “”:

 messagebox.showerror(“Account Creation Failed”, “Please enter both username and password.”)


z
z

 Else:

 questions = [

 “What is your favorite sport?”,

 “What is your pet’s name?”,

 “What city were you born in?” ]

 question_selection =

 simpledialog.askstring(“Select Security Question”,

 f”Choose a security

 question:\n1. {questions[0]}\n2.

 {questions[1]}\n3.

 {questions[2]}\n\nEnter 1, 2, or 3:”)
z
z

If question_selection in [‘1’, ‘2’, ‘3’]:

question_index = int(question_selection) – 1
 answer = simpledialog.askstring(“Answer Security Question”,

 questions[question_index])

 if answer:

 accounts[username] = {

 ‘password’: password,

 ‘security_question’:

 questions[question_index],

 ‘security_answer’:

 answer

 }
z

Messagebox.showinfo(“Account Created”, f”Account created


successfully for {username}!”)

username_entry.delete(0, tk.END)

password_entry.delete(0, tk.END)

else: messagebox.showerror(“Account Creation


Failed”, “Please answer the security question.”)
 else:

 messagebox.showerror(“Error”, “Invalid selection. Please


enter 1, 2, or 3.”)
z
z
z

Def forgot_password():

username = simpledialog.askstring(“Forgot Password”, “Enter your


username:”)

if username not in accounts:

messagebox.showerror(“Error”, “Username not found.”)

return

question = accounts[username][‘security_question’]
 answer = simpledialog.askstring(“Answer Security Question”,
question)
z
z

If answer:

stored_answer = accounts[username][‘security_answer’]

if answer == stored_answer:
 new_password = simpledialog.askstring(“Reset

 Password”, “Enter your new

 password:”, show=“*”)

 if new_password accounts[username][‘password’] =

 new_password messagebox.showinfo(“Success”, “Password reset successfully!”)

 else:

 messagebox.showerror(“Error”, “No password entered.”)

 else:

 messagebox.showerror(“Error”, “Incorrect answer to the security question.”)


z
z

Def verify_password():

username = username_entry.get()

password = password_entry.get()

if username in accounts and accounts[username][‘password’] == password:

messagebox.showinfo(“Login Successful”, f”Welcome {username}!”)

else:

messagebox.showerror(“Login Failed”, “Invalid username or password.”)

def enter_pressed(event):

if event.widget == username_entry:

password_entry.focus_set()
 elif event.widget ==

 password_entry:

 verify_password()
z

Root = tk.Tk()

root.title(“Pulung Santol Sports Portal”)

root.geometry(“300x300”)

root.config(bg=“#cceeff”)

main_frame = tk.Frame(root, bg=“#cceeff”, padx=20, pady=20)

main_frame.pack(expand=True)

title_label = tk.Label(main_frame, text=“PULUNG SANTOL SPORTS PORTAL”, font=(“Arial”,


12, “bold”), bg=“#cceeff”)
 title_label.pack(pady=5)
z
z

Credentials_frame = tk.Frame(main_frame, bg=“#cceeff”)

credentials_frame.pack(pady=5)

username_label = tk.Label(credentials_frame, text=“Username:”,


font=(“Arial”, 10), bg=“#cceeff”)

username_label.grid(row=0, column=0, padx=5, sticky=“w”)

username_entry = tk.Entry(credentials_frame, font=(“Arial”, 10),


width=15)
 username_entry.grid(row=0, column=1, padx=5)
z

Password_label = tk.Label(credentials_frame, text=“Password:”,


font=(“Arial”, 10), bg=“#cceeff”)

password_label.grid(row=1, column=0, padx=5, sticky=“w”)

password_entry = tk.Entry(credentials_frame, font=(“Arial”, 10),


show=“*”, width=15)
 password_entry.grid(row=1, column=1, padx=5)
z

Username_entry.bind(‘<Return>’, enter_pressed)

password_entry.bind(‘<Return>’, enter_pressed)

login_button = tk.Button(credentials_frame, text=“Login”, font=(“Arial”, 10),


command=verify_password)

login_button.grid(row=1, column=2, padx=5)

button_frame = tk.Frame(main_frame, bg=“#cceeff”)


 button_frame.pack(pady=10)
z

Create_account_button = tk.Button(button_frame, text=“Create


Account”, font=(“Arial”, 10), command=create_account)

create_account_button.grid(row=0, column=0, padx=10)

forgot_password_button = tk.Button(button_frame, text=“Forgot


Password”, font=(“Arial”, 10), command=forgot_password)
 forgot_password_button.grid(row=0, column=1, padx=10)
z

Set_focus()
 root.mainloop()
z
z
z

You might also like