forgotpassword.
py
from tkinter import *
from tkinter import messagebox
import [Link]
def main():
def submit():
email = email_entry.get()
new_password = new_password_entry.get()
confirm_password = confirm_password_entry.get()
if not email or not new_password or not confirm_password:
[Link]('Error', 'All fields are required.')
return
if new_password != confirm_password:
[Link]('Error', "Passwords don't match.")
return
# Database connection and password update logic
mydb = [Link](
host="localhost",
user="root",
password="12345678",
database='p_registration' # Connect to the existing database
mycursor = [Link]()
#[Link]('use p_registration') # Replace with your database name
query = 'UPDATE personaldata SET password = %s WHERE email = %s'
[Link](query, (new_password, email))
[Link]()
[Link]()
[Link]()
[Link]('Success', 'Password updated successfully. Please login with your
new password.')
[Link]()
import loginpg # Make sure [Link] exists and is properly set up
[Link]() # Assuming [Link] has a main() function to initiate the login screen
window = Tk()
[Link]('Forgot Password')
[Link]('500x460+200+10')
# Email Entry
email_label = Label(window, text='Email:')
email_label.pack()
email_entry = Entry(window, width=30)
email_entry.pack()
# New Password Entry
new_password_label = Label(window, text='New Password:')
new_password_label.pack()
new_password_entry = Entry(window, width=30, show='*')
new_password_entry.pack()
# Confirm New Password Entry
confirm_password_label = Label(window, text='Confirm New Password:')
confirm_password_label.pack()
confirm_password_entry = Entry(window, width=30, show='*')
confirm_password_entry.pack()
# Submit Button
submit_button = Button(window, text='Submit', command=submit)
submit_button.pack()
[Link]()
if __name__ == "__main__":
main()