Name Error,can't find what is wrong with it. NameError: name 'student_ID' is not defined

Viewed 27

I have added the code where I import.

Here is the code where I import

And I have defined reg before importing this function and I still have the same issue.I checked it over and over again. Still can't find where else to adjust.

from questions import Student
import mysql.connector

mycon = mysql.connector.connect(host='127.0.0.1', user='root', passwd='', database='Exam')
mycursor = mycon.cursor()

myquery = "INSERT INTO studentinfo (student_ID, full_name, level, Department, username, password) VALUES(%s, %s, %s, %s, %s, %s)"

reg = (student_ID, full_name, level, Department, username, password)

Student()

mycursor.execute(myquery, reg)

mycon.commit()

print("Login Successful")

print("Welcome to your Exam Page!!!")


class Student():

    def __init__(self):
        
        self. student_ID = student_ID
        self.full_name = full_name
        self.level = level
        self.department = department
        self.user = user
        self.passwd = passwd


student_ID = input("Enter 5 digits for your student ID")
full_name = input("Enter your full name>>>:")
level = input("Enter your level")
department = input("Enter your department>>>:")
user = input("Enter your username>>>:")
passwd = input("Enter your password>>>:")

reg = Student()
print("Registration Successful")
print("Please Login")

username = input("Enter your username to login")
password = input("Enter your password")
if user == username and passwd == password:
    print("Login Successful")
    print("Welcome to your Exam Page,Goodluck!")
else:
    print("Login Error")
0 Answers
Related