I am having trouble running if part of code where user name and password is wrong.program does not show any error. And how can i set userfullname of Index class to lable in admin_object = userFullname.setText() ?
import sqlite3
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import QMessageBox
from Login_form import Login_form
from Admin_Home_form import AdminHome_Form
class Index(QtWidgets.QDialog, Login_form):
def __init__(self):
QtWidgets.QDialog.__init__(self)
self.loginFormDesign(self)
self.login_button.clicked.connect(self.login_check)
def login_check(self):
uname = self.U_name_text.text()
password = self.pass_text.text()
# self.userfullname = userfullname
connection = sqlite3.connect("taylorDB.db")
result = connection.execute("SELECT USER_EMAIL FROM USERS WHERE USER_EMAIL = ? AND USER_PASSWORD = ?",
(uname, password))
for dbemail in result: # After this code does not work if value does not match
print(dbemail[0])
if dbemail[0] != uname:
buttonReply = QMessageBox.question(self, 'Login Invalid', "Check User Name or Password!",
QMessageBox.Close)
if buttonReply == QMessageBox.Close:
print("invalid login")
else:
result = connection.execute("SELECT USER_FULLNAME FROM USERS WHERE USER_EMAIL = ?", (dbemail))
self.userfullname = result.fetchone()
print(self.userfullname)
self.accept()
class admin_operation(QtWidgets.QMainWindow, AdminHome_Form, Index):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.adminHomeFormDesign(self)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
login_object = Index()
admin_object = admin_operation()
if login_object.exec() == QtWidgets.QDialog.Accepted:
# admin_object.userFullname.setText() #I want to set the value of userfullname here?
admin_object.show()
sys.exit(app.exec_())
My basic are not so strong please guide me .