Page 57 - Phyton_GUIprogrammingwithTkinter
P. 57

P a ge  | 48

































                                              Figure 2.0: Registration Form

               Registration Form Code


                 from tkinter import *
                 from tkinter.ttk import Combobox
                 from tkinter import messagebox
                 import mysql.connector as mysql

                 def register ():
                     NAME=name.get ()
                     AGE=age.get ()
                     EMAIL=email.get ()
                     GENDER=gender.get ()
                     CITY=city.get ()
                     STATE=state.get ();

                 if (NAME=="" or AGE==""or EMAIL==""or GENDER==""or CITY=="" or
                 STATE==""):
                  messagebox.showinfo("Registration Status", "All Fields are
                 required")
                  else:
                        con=mysql.connect(host="localhost", user="root",
                 password="", database="employee")
                         cursor=con.cursor()
                         cursor.execute("insert into staff values('"+ NAME +"','"+
                 AGE +"','"+EMAIL+"','"+str(GENDER)+"',
                         '"+CITY+"','"+STATE+"')")
                         cursor.execute("commit");
                         messagebox.showinfo("Registration Status", "Inserted
                 Successfully");
                         con.close();
   52   53   54   55   56   57   58   59   60   61   62