Unable to redirect to register page

Jagdeesh Sandhu

When I run my login page and click the sign up button, it does not redirect to the register page but it just maintains at the login page

import register  
import pymysql

class Login:


    def __init__(self,root):
        self.root=root
        self.root.title("Scheduling Management System")
        self.root.geometry("1350x768+0+0")
        self.root.resizable(False,False)

        self.txt_user = StringVar()
        self.txt_pass = StringVar()
        self.bg = ImageTk.PhotoImage(file = "Images/bgimage.jpg")
        bg = Label(self.root,image=self.bg).place(x = 0, y= 0, relwidth = 1, relheight = 1)
        framelogin = Frame(self.root,bg="white")
        framelogin.place(x=450,y=100,height=500,width=700)

        title=Label(framelogin,text="Login Here",font=("Arial",30,"bold"),fg="orange",bg="white").place(x=90,y=30)
        nexttitle=Label(framelogin,text="Scheduling Staff System",font=("Times New Roman",18,"bold"),fg="orange",bg="white").place(x=90,y=100)

        userlabel=Label(framelogin,text="Username",font=("Arial",15,"bold"),fg="gray",bg="white").place(x=90,y=140)
        self.txt_user=Entry(framelogin,textvariable = self.txt_user,font=("times new roman",15),bg="lightgray")
        self.txt_user.place(x=90,y=170,width=350,height=35)

        passlabel=Label(framelogin,text="Password",font=("Arial",15,"bold"),fg="gray",bg="white").place(x=90,y=210)
        self.txt_pass=Entry(framelogin,textvariable = self.txt_pass,font=("times new roman",15),show="*",bg="lightgray")
        self.txt_pass.place(x=90,y=240,width=350,height=35)

        forget=Button(framelogin,text="Forgot Password",bg="white",fg="orange",font=("trebuchet ms",12)).place(x=90,y=305)
        reglabel=Label(framelogin,text="Don't Have an Account?",font=("trebuchet ms",12,"bold"),fg="orange",bg="white").place(x=320,y=310)
        registerbutton=Button(framelogin,text="Sign Up",command=register,bg="white",fg="orange",font=("trebuchet ms",12)).place(x=510,y=305)

        loginbutton=Button(framelogin,text="Login",command=self.login,fg="white",bg="orange",font=("sans serif ms",20)).place(x=90,y=350,width="100",height="40")

    def login(self):
        if self.txt_user.get() == "" or self.txt_pass.get() == "":
            messagebox.showerror("Error", "Please fill up all fields!")


root = Tk()
obj = Login(root)
root.mainloop()

Here is my register page

from tkinter import *
from tkinter import ttk, messagebox

import PIL
import pymysql
from PIL import ImageTk
from PIL import Image

class Register:
    def __init__(self, root):
        self.root = root
        self.root.title("Registration Page")
        self.root.geometry("1350x768+0+0")
        self.root.config(bg="light blue")

        self.bg = ImageTk.PhotoImage(file="Images/bgimage.jpg")
        bg = Label(self.root,image=self.bg).place(x = 0, y= 0, relwidth = 1, relheight = 1)
        frame1=Frame(self.root,bg="white")
        frame1.place(x=450,y=100,width=700,height=600)

        title=Label(frame1,text="Please enter your information here",font=("trebuchet ms",20,),bg="white",fg="black").place(x=50, y=30)


        fname=Label(frame1,text="First Name",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=50, y=100)
        self.text_fname=Entry(frame1,font=("arial",15,),bg="lightgray")
        self.text_fname.place(x=50, y=130, width=250)
        lname=Label(frame1,text="Last Name",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=370, y=100)
        self.text_lname=Entry(frame1,font=("arial",15,),bg="lightgray")
        self.text_lname.place(x=370, y=130, width=250)
        contact=Label(frame1,text="Contact Number",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=50, y=170)
        self.text_contact=Entry(frame1,font=("arial",15,),bg="lightgray")
        self.text_contact.place(x=50, y=200, width=250)
        email=Label(frame1,text="Email Address",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=370, y=170)
        self.text_email=Entry(frame1,font=("arial",15,),bg="lightgray")
        self.text_email.place(x=370, y=200, width=250)
        question=Label(frame1,text="Security Question",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=50, y=240)
        self.cmbquestion=ttk.Combobox(frame1,font=("times new roman",13),state='readonly',justify=CENTER)
        self.cmbquestion['values']=("Select","Your First Car","Your Mothers First Name", "Your Best Friend Name")
        self.cmbquestion.place(x=50, y=270, width=250)
        self.cmbquestion.current(0)
        answer=Label(frame1,text="Answer",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=370, y=240)
        self.text_answer=Entry(frame1,font=("arial",15,),bg="lightgray")
        self.text_answer.place(x=370, y=270, width=250)
        pwd=Label(frame1,text="Password",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=50, y=310)
        self.text_pwd=Entry(frame1,font=("arial",15,),show="*",bg="lightgray")
        self.text_pwd.place(x=50, y=340, width=250)
        cfmpwd=Label(frame1,text="Confirm Password",font=("times new roman",15,"bold"),bg="white",fg="black").place(x=370, y=310)
        self.text_cfmpwd=Entry(frame1,font=("arial",15,),show="*",bg="lightgray")
        self.text_cfmpwd.place(x=370, y=340, width=250)

        self.btn= ImageTk.PhotoImage(file="images/register.png")
        btn = Button(frame1,image=self.btn, bd=0, command = self.registerdata,cursor = "hand2").place(x=50, y = 420)



    def registerdata(self):
        if self.text_fname.get()=="" or self.text_lname.get()=="" or self.text_contact.get()=="" or self.text_email.get()=="" or self.cmbquestion.get()=="Select" or self.text_pwd.get()=="" or self.text_cfmpwd.get()=="":
            messagebox.showerror("Error","All fields are required!",parent=self.root)
        elif self.text_pwd.get()!=self.text_cfmpwd.get():
            messagebox.showerror("Error","Passwords must be the same!",parent=self.root)
        else:
            try:
                con=pymysql.connect(host="localhost",user="root",password="",database="employee")
                cur=con.cursor()
                cur.execute("select * from employeelist where email=%s", self.text_email.get())
                row=cur.fetchone()
                print(row)
                if row!=None:
                    messagebox.showerror("Error","User Already Exists. Please Register With a New Email",parent=self.root)
                else:
                    cur.execute("insert into employeelist (fname,lname,contact,email,question,answer,password) values(%s,%s,%s,%s,%s,%s,%s)",
                                (self.text_fname.get(),self.text_lname.get(),self.text_contact.get(),self.text_email.get(),self.cmbquestion.get(),self.text_answer.get(),self.text_pwd.get()))
                    con.commit() #do changes to database
                    con.close()
                    messagebox.showinfo("Success","Registration Successful",parent=self.root)
            except Exception as ex:
                messagebox.showerror("Error",f"Error due to: {str(ex)}",parent=self.root)


root = Tk()
obj = Register(root)
root.mainloop()

I have inserted the action for the button as command = register but it is still not redirecting to the register page. Is there any error with my command function?

acw1668

Better move the main block code inside register.py in a function:

class Register:
    ...

def RegisterForm():
    win = Toplevel()
    obj = Register(win)

Then you can use this function inside the login page:

import register
...

class Login:
    def __init__(self):
        ...
        Button(framelogin,text="Sign Up",command=self.register,bg="white",fg="orange",font=("trebuchet ms",12)).place(x=510,y=305)
        ...

    def register(self):
        register.RegisterForm()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

.htaccess file unable to redirect page

From Dev

Prevent automatic login when register in woocommerce and redirect to login page?

From Dev

How to redirect to previous page after successful register in Laravel?

From Dev

unable to redirect from servlet to jsp page

From Dev

unable to redirect on wp-admin page

From Dev

How can i exclude my register page from Form Authentication Redirect to login page

From Dev

redirect with subdomain fails to register

From Dev

Selenium Webdriver - Unable to find element after page refresh/redirect

From Dev

After insert redirect to edit page. Unable to get ID

From Dev

Selenium Webdriver - Unable to find element after page refresh/redirect

From Dev

Unable to Redirect to different page on click ? mvc4

From Dev

Unable to redirect to application page even after successful authentication in CAS server

From Dev

Unable to redirect a user to a desired page after login with Spring Security

From Dev

Unable to pull :page params from the URL on 301 router redirect

From Dev

Unable to use filefilter to redirect other page in express js

From Dev

How can i Redirect customer to "Register" page if use email address and password is wrong?

From Dev

ActiveAdmin, register_page and register

From Dev

Unable to register a blueprint

From Dev

Unable to register NSD Service

From Dev

Unable to register a blueprint

From Dev

Unable to register IRequestPreProcessors with Mediatr

From Dev

Unable to register kprobe

From Dev

Flask-Security Register Redirect

From Dev

Register page with Spring Security

From Dev

Django/Python register page

From Dev

if user_name is already registered, redirect back to the same page ex. register.php?q=user_exists

From Dev

php register page won't register user

From Dev

php register page won't register user

From Dev

.htaccess - redirect to specific page + redirect to /

Related Related

  1. 1

    .htaccess file unable to redirect page

  2. 2

    Prevent automatic login when register in woocommerce and redirect to login page?

  3. 3

    How to redirect to previous page after successful register in Laravel?

  4. 4

    unable to redirect from servlet to jsp page

  5. 5

    unable to redirect on wp-admin page

  6. 6

    How can i exclude my register page from Form Authentication Redirect to login page

  7. 7

    redirect with subdomain fails to register

  8. 8

    Selenium Webdriver - Unable to find element after page refresh/redirect

  9. 9

    After insert redirect to edit page. Unable to get ID

  10. 10

    Selenium Webdriver - Unable to find element after page refresh/redirect

  11. 11

    Unable to Redirect to different page on click ? mvc4

  12. 12

    Unable to redirect to application page even after successful authentication in CAS server

  13. 13

    Unable to redirect a user to a desired page after login with Spring Security

  14. 14

    Unable to pull :page params from the URL on 301 router redirect

  15. 15

    Unable to use filefilter to redirect other page in express js

  16. 16

    How can i Redirect customer to "Register" page if use email address and password is wrong?

  17. 17

    ActiveAdmin, register_page and register

  18. 18

    Unable to register a blueprint

  19. 19

    Unable to register NSD Service

  20. 20

    Unable to register a blueprint

  21. 21

    Unable to register IRequestPreProcessors with Mediatr

  22. 22

    Unable to register kprobe

  23. 23

    Flask-Security Register Redirect

  24. 24

    Register page with Spring Security

  25. 25

    Django/Python register page

  26. 26

    if user_name is already registered, redirect back to the same page ex. register.php?q=user_exists

  27. 27

    php register page won't register user

  28. 28

    php register page won't register user

  29. 29

    .htaccess - redirect to specific page + redirect to /

HotTag

Archive