Advertisement
Guest User

Login Method

a guest
Apr 24th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. def log_in(self):
  2. user = self.user_entry.get()
  3. password = self.password_entry.get()
  4. get_users = ("SELECT * from user WHERE username = %s")
  5. self.controller.cursor.execute(get_users, (user,))
  6. uname = self.controller.cursor.fetchone()
  7. if uname == None:
  8. tkmb.showerror("Error", "Username not in database.")
  9. else:
  10. uname = list(uname)
  11. if uname[1] != password:
  12. tkmb.showerror("Error", "Password is incorrect.")
  13. else:
  14. self.controller.cnx = mysql.connector.connect(user=user, password=password,
  15. host='localhost', database='gt_train')
  16. self.controller.cursor = self.controller.cnx.cursor()
  17. self.controller.current_user = user
  18. print self.controller.current_user
  19. self.controller.show_frame("ChooseFunctionality_Customer")
  20.  
  21. # userExists = False;
  22. # login_success = False;
  23. # for (uname, pword) in self.controller.cursor:
  24. # if uname==user:
  25. # userExists = True;
  26. # if pword==password:
  27. # login_success = True;
  28. # else:
  29. # tkmb.showerror("Error", "Password is incorrect.")
  30. # if not userExists:
  31. # tkmb.showerror("Error", "Username not in database.")
  32. # if login_success:
  33. # self.controller.cnx = mysql.connector.connect(user=user, password=password,
  34. # host='localhost', database='gt_train')
  35. # self.controller.cursor = self.controller.cnx.cursor()
  36. # self.controller.current_user = user
  37. # self.controller.show_frame("ChooseFunctionality_Customer")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement