0% found this document useful (0 votes)
4 views3 pages

Forgotpassword Python Code

The document is a Python script for a 'Forgot Password' feature using Tkinter for the GUI and MySQL for database interaction. It allows users to enter their email and new password, validates the inputs, and updates the password in the database if the inputs are correct. Upon successful update, it informs the user and transitions to a login page.

Uploaded by

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

Forgotpassword Python Code

The document is a Python script for a 'Forgot Password' feature using Tkinter for the GUI and MySQL for database interaction. It allows users to enter their email and new password, validates the inputs, and updates the password in the database if the inputs are correct. Upon successful update, it informs the user and transitions to a login page.

Uploaded by

dung.trieu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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()

You might also like