0% found this document useful (0 votes)
20 views

Mithun Python Project

The document describes a login and registration system using Python and MySQL. It includes functions for registering new users, logging in existing users, updating user details, and displaying a list of registered users. Screenshots and additional requirements are also mentioned.

Uploaded by

jagan20102007
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)
20 views

Mithun Python Project

The document describes a login and registration system using Python and MySQL. It includes functions for registering new users, logging in existing users, updating user details, and displaying a list of registered users. Screenshots and additional requirements are also mentioned.

Uploaded by

jagan20102007
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
You are on page 1/ 16

INDEX

1.Certificate
2.Acknowledgement
3.Additional file
4.Coding
5.ScreenShots(Output)
6.Requirement 7.Bibliography

ADDITIONAL FILE
(Libraries)

• tkinter :- For GUI designing for project.


• mysql.connector :- For connecting with mysql.
CODING
# ==============modules================
from tkinter import * import
mysql.connector as my

conn = my.connect(host="localhost", user="root", passwd="mps",


database="login_system",charset="utf8") mycursor = conn.cursor()
mycursor.execute("CREATE TABLE If NOT EXISTS UserDetail (id int
auto_increment primary key, name varchar(35), username varchar(25), phone
varchar(11), password varchar(255))")

#updation data on server def


update_user():
cname = name_upd.get() cuser = user_upd.get()
cphone = phone_upd.get() cid = c_id cuser_valid =
cname_valid = cphone_valid = False
error_list.delete(0,END) if len(cuser) > 0 and len(cname)
> 0 and len(cphone) > 0:
if len(cname) > 30:
error = "Fullname contains only 30 character"
error_list.insert(END, error) else:
cname_valid = True

if (len(cuser) >= 4 and len(cuser) < 20) == False:


error = "Username must be between 4 to 30 character long"
error_list.insert(END, error) else:
cuser_valid = True if (cphone.isdigit() and
(len(cphone) == 10)) == False:
error = "Please enter valid phone number"
error_list.insert(END, error) else:
cphone_valid = True if cname_valid ==
cuser_valid == cphone_valid:
# ============Updation code mycursor.execute("SELECT *
FROM UserDetail WHERE (username = '"+cuser+"' AND NOT id = '"+cid+"')
OR (phone = '"+cphone+"' AND NOT id =
'"+cid+"')") result =
mycursor.fetchall() if
(len(result) == 0):
name_upd.delete(0, END)
phone_upd.delete(0, END) user_upd.delete(0,
END)

query = "UPDATE UserDetail SET name = '"+cname+"' ,username =


'"+cuser+"', phone = '"+cphone+"' WHERE id = '"+cid+"' "
mycursor.execute(query)

conn.commit() if
(mycursor.rowcount > 0):
error_list.insert(END,"Successfully Registered")
else:
error_list.insert(END,"Some problem occurs during updation")
else:
error_list.insert(END, "Please enter Another username or phone number")
# ============Updation end
else:
error = "All fields are required"
error_list.insert(END, error)

#registered users def


user_form():
global frame_user frame_user = Frame(screen3) row=0
mycursor.execute("SELECT * FROM UserDetail ORDER BY id asc")

Label(frame_user,text="Id",fg="#fff",bg="#373737",pady=10,width=5,font=("Bold",1
0)).grid(row=row,column=0)

Label(frame_user,text="FullName",bg="#373737",fg="#fff",pady=10,width=15,font=(
"bold",10)).grid(row=row,column=1)

Label(frame_user,text="UserName",bg="#373737",fg="#fff",pady=10,width=20,font=
("bold",10)).grid(row=row,column=2)

Label(frame_user,text="Phone",bg="#373737",fg="#fff",pady=10,width=15,font=("bo
ld",10)).grid(row=row,column=3)
Label(frame_user, width=15, font=("bold", 10)).grid(row=0, column=4)
row=row+1 results = mycursor.fetchall()
for result in results:
id=str(result[0]) if
row%2==0:
bg="#fff"
fg="#999" else:
bg="#999"
fg="#fff"
Label(frame_user, text=id, bg=bg, fg=fg, width=5, pady=10, font=("bolder",
10)).grid(row=row, column=0)
Label(frame_user, text=result[1], bg=bg, fg=fg, width=15, pady=10, font=("bold",
10)).grid(row=row, column=1)
Label(frame_user, text=result[2], bg=bg, fg=fg, width=20, pady=10, font=("bold",
10)).grid(row=row, column=2)
Label(frame_user, text=result[3], bg=bg, fg=fg, width=15, pady=10, font=("bold",
10)).grid(row=row, column=3)
Button(frame_user,text="UPDATE" ,bg="green",
fg="#fff",font=("bold",10),command=lambda
upd=id:update(upd)).grid(row=row,column=4)
Button(frame_user, text="DELETE", bg="#d9534f", fg="#f9f9f9",font=("bold",
10),command=lambda det=id:delete(det)).grid(row=row, column=5)
row = row+1 if len(results) == 0:
Label(frame_user,text="No User existed",fg="#969696",font=("dancing
script",15)).grid(row=row,column=0,columnspan=5) try:
screen3.destroy()
except: pass
frame_user.place(x=100,y=150)

#update user data form def


update(id):
global upd_screen1,name_upd,user_upd, phone_upd, c_id, error_list
c_id=id mycursor.execute("SELECT * FROM UserDetail WHERE id =
'"+id+"'") result = mycursor.fetchall() name_val = result[0][1]
user_val = result[0][2] phone_val = result[0][3] screen3.destroy()
upd_screen1 = Toplevel(screen) upd_screen1.title("Update detail of
"+user_val) upd_screen1.geometry("700x1000") upd_screen =
Frame(upd_screen1,width=100) name = StringVar() phone =
StringVar() username = StringVar()
Label(upd_screen, text="Enter Fullname
*",padx=100,pady=20).grid(row=1,column=0) name_upd =
Entry(upd_screen, textvariable=name, bg="#eee")
name_upd.grid(row=1,column=1)
Label(upd_screen, text="Enter Username *",pady=20).grid(row=2,column=0)
user_upd = Entry(upd_screen,textvariable=username, bg="#eee")
user_upd.grid(row=2,column=1)
Label(upd_screen, text="Enter Phone number *",pady=20).grid(row=3,column=0)
phone_upd = Entry(upd_screen, textvariable=phone, bg="#eee")
phone_upd.grid(row=3,column=1)
Label(upd_screen).grid(row=4,column=0)

Button(upd_screen, text="Update", bg="green", fg="#fff", width="20", height="1",


font=("arial", 10),command=update_user).grid(row=5,column=0,columnspan=2)
Button(upd_screen, text="Back", width="12", bg="#d9534f", fg="#f9f9f9",
font=("bold", 10),command=welcome).grid(row=6,column=0,columnspan=2)
name_upd.insert(END,name_val) user_upd.insert(END,user_val)
phone_upd.insert(END,phone_val) frame = Frame(upd_screen) scroll =
Scrollbar(frame, bg="#efefef", activebackground="#999", width='15')
scroll.pack(side=RIGHT, fill=Y) error_list = Listbox(frame, bg="#ddd",
fg="#000", border=0, width='55',height='4', yscrollcommand=scroll.set)
error_list.pack(side=LEFT) scroll.config(command=error_list.yview)
frame.grid(row=8,column=0,columnspan=2) upd_screen.place(x=100,y=50)

#delete user function def


delete(id):
mycursor.execute("SELECT * FROM UserDetail WHERE id = '"+id+"'")
result=mycursor.fetchall() if(len(result) > 0):
mycursor.execute("delete from userdetail where id='"+id+"'")
frame_user.destroy() print("hello") user_form()

#welcome page def


welcome():
global screen3 try:
screen1.destroy()
except: try:
upd_screen1.destroy()
except:
pass
screen3 = Toplevel(screen)
screen3.geometry("1000x1000")
Button(screen3, text="LogOut", bg="#d9534f", fg="#f9f9f9", width='10',
font=("bold", 10), command=screen3.destroy).place(x=800,y=0)
#Label(screen3, text="Welcome " + data[0][1] + ", its a very nice meeting of
you", width=40, fg="#262626", font=("dancing script", 10)).place(x=15, y=90)
user_form()

#login user function def login_user():


global data user = username.get()
passcode = password.get()
error_list.delete(0, END) if len(user)
> 0 and len(passcode) > 0:
user_field.delete(0, END) pass_field.delete(0, END)
mycursor.execute('SELECT * FROM UserDetail WHERE username ="' + user +
'"')
data = mycursor.fetchall()
if (len(data) == 1):
if (data[0][4] == passcode):
for i in range(5): if (i
== 0):
error_list.insert(END, "WELCOME " + data[0][1])
welcome() else:
error_list.insert(END, "Please input valid password")
else:
error_list.insert(END, "Username not found")

else:
error = "Please input Your username and password"
error_list.insert(END, error)

#registor user function def


register_user():
user = username.get() passcode = password.get() fullname = name.get()
number = phone.get() error_list.delete(0, END) user_valid = passcode_valid =
fullname_valid = number_valid = False if len(user) > 0 and len(passcode) > 0
and len(fullname) > 0 and len(number) > 0: if len(fullname) > 30:
error = "Fullname contains only 30 character"
error_list.insert(END, error)
else:
fullname_valid = True if (len(user) >=
4 and len(user) < 20) == False:
error = "Username must be between 4 to 30 character long"
error_list.insert(END, error) else:
user_valid = True if (number.isdigit() and
(len(number) == 10)) == False:
error = "Please enter valid phone number"
error_list.insert(END, error) else:
number_valid = True
if len(passcode) < 6:
error = "Password must be atleast 6 character long"
error_list.insert(END, error) else:
passcode_valid = True if fullname_valid == user_valid ==
passcode_valid == number_valid:
# ============Insertion code mycursor.execute("SELECT *
FROM UserDetail WHERE username =%s OR phone=%s", (user, number))
result = mycursor.fetchall()
if (len(result) == 0):
user_registor_field.delete(0, END)
phone_registor_field.delete(0, END)
name_registor_field.delete(0, END)
password_registor_field.delete(0, END) query = "INSERT INTO
UserDetail(name,username,phone,password) VALUES(%s,%s,%s,%s)"

values = (fullname, user, number, passcode)


mycursor.execute(query, values)
conn.commit() if (mycursor.rowcount > 0):
error_list.insert(END, "Successfully Registered")
else:
error_list.insert(END, "Some problem occurs during registration")
else:
error_list.insert(END, "Please enter Another username or phone number")
else:
error = "All fields are required"
error_list.insert(END, error)
#login form def
login():
global username, password, screen1, user_field, pass_field, error_list
screen1 = Toplevel(screen) screen1.geometry("700x800")
screen1.title("Login") logScr= Frame(screen1)
Label(logScr, text="Enter following detail to login", bg="#fe51ad",padx=120,
fg="#fff", font=("dancing script",
14)).grid(row=0,column=0,columnspan=2) username = StringVar()
password = StringVar()
Label(logScr, text="Enter Username *",padx=100,pady=20).grid(row=1,column=0)
user_field = Entry(logScr, textvariable=username, bg="#eee")
user_field.grid(row=1,column=1)
Label(logScr, text="Enter Password *",pady=20).grid(row=2,column=0)
pass_field = Entry(logScr, textvariable=password, show="*", bg="#eee")
pass_field.grid(row=2,column=1)
Label(logScr).grid(row=3,column=0)
Button(logScr, text="LOGIN", bg="#fe51ab", fg="#fff", width="20", height="1",
font=("arial", 10),
command=login_user).grid(row=4,column=0,columnspan=2)
Button(logScr, text="Back", width=12, bg="#d9534f", fg="#f9f9f9", font=("bold",
10), command= screen1.destroy).grid(row=5, column=0,columnspan=2)
Label(logScr).grid(row=6,column=0) frame = Frame(logScr,
width=250) error_list = Listbox(frame, border=0, width='75',
bg="#ddd", fg="#ff9494",font=(7)) error_list.pack(side=LEFT)
frame.grid(row=7,column=0,columnspan=2) logScr.place(x=0,y=0)

#registor form def


register():
global screen2, name, phone, username, password, error_list, user_registor_field,
name_registor_field, phone_registor_field, password_registor_field screen2 =
Toplevel(screen) screen2.geometry("700x800") screen2.title("Register
yourself") regScr= Frame(screen2)
Label(regScr, text="Enter following detail to be with us", bg="#fe51ad", fg="#fff",
padx=120, font=("dancing script", 14)).grid(row=0,column=0,columnspan=2)
name = StringVar() phone = StringVar() username = StringVar() password =
StringVar()
Label(regScr, text="Enter Fullname *",padx=100,pady=20).grid(row=1,column=0)
name_registor_field = Entry(regScr, textvariable=name, bg="#eee")
name_registor_field.grid(row=1,column=1)

Label(regScr, text="Enter Username *",pady=20).grid(row=2,column=0)


user_registor_field = Entry(regScr, textvariable=username, bg="#eee")
user_registor_field.grid(row=2,column=1)
Label(regScr, text="Enter Phone number *",pady=20).grid(row=3,column=0)
phone_registor_field = Entry(regScr, textvariable=phone, bg="#eee")
phone_registor_field.grid(row=3,column=1)
Label(regScr, text="Enter Password *",pady=20).grid(row=4,column=0)
password_registor_field = Entry(regScr, textvariable=password, bg="#eee")
password_registor_field.grid(row=4,column=1)
Label(regScr).grid(row=5,column=0)
Button(regScr, text="PROCEDE", bg="#fe51ab", fg="#fff", width="20", height="1",
font=("arial", 10),
command=register_user).grid(row=6,column=0,columnspan=2)
Button(regScr, text="Back", width="12", bg="#d9534f", fg="#f9f9f9", font=("bold",
10),
command=screen2.destroy).grid(row=7,column=0,columnspan=2)
Label(regScr).grid(row=8,column=0,columnspan=2)
# ===========================
frame = Frame(regScr)
scroll = Scrollbar(frame, bg="#efefef", activebackground="#999", width=15)
scroll.pack(side=RIGHT, fill=Y) error_list = Listbox(frame, bg="#ddd",
fg="#ff9494", border=0, width='75',font=(7), yscrollcommand=scroll.set)
error_list.pack(side=LEFT) scroll.config(command=error_list.yview)
frame.grid(row=9,column=0,columnspan=2) regScr.place(x=0,y=0)

def home():
global screen
screen = Tk()
screen.title("WELCOME TO SCHOOL MANAGEMENT SYSTEM")
screen.geometry("1000x1000")
Label(screen, text="WELCOME TO SCHOOL MANAGEMENT SYSTEM",
bg="#fe51ad", width=1000, height=2, fg="#fff", font=("dancing script",
15)).pack()
Label().pack()
Button(text="Login", height=3, width=40, bg="green", fg="#fff", font=("Arial", 12),
command=login).pack()
Label().pack()
Button(text="Register", height=3, width=40, bg="gold", fg="#fff", font=("arial",
12), command=register).pack()
Label().pack()
Label().pack()
Button(text="EXIT", width=20, bg="#d9534f", fg="#f9f9f9", font=("bold", 10),
command=screen.destroy).pack()
screen.mainloop()

home()
ScreenShots (Output)
Requirement

❖ Hard Disk :- 500GB


❖ RAM :- 1GB
❖ PyCharm IDE :-A python editor/IDE
❖ Processor :- Intel i3 7th Generation
❖ Printer
Bibliography

1. Https://youtube.com
2. Https://google.com
3. NCERT Textbook
4. Self Learning
5. Self Analyzing

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy