title: i've confused myself with validation. I was trying to make a login/registry function and have found it hard to validate login details to my database
body: <p>I am trying to make a login/registry function using tkinter in python, but have confused myself with the validation through the login function. It should connect with the database and see if the fields are correct, but I can't figure out how to do it.</p>
  
  <pre class="lang-py prettyprint-override"><code>def login_verify():
      global c
  
      with sqlite3.connect('database.db') as db:
          c = db.cursor()
  
      username1 = username_verify.get()
      password1 = password_verify.get()
      username_login_entry.delete(0, END)
      password_login_entry.delete(0, END)
  
      finduser = ('SELECT * FROM Users WHERE username =? AND password =?')
      c.execute(finduser,[(username1),(password1)])
      results = c.fetchall()
      if results:
          login_sucess()
  
      else:
          password_not_recognised()
          user_not_found()
  
  def login_success():
      global login_success_screen
      login_success_screen = Toplevel(login_screen)
      login_success_screen.title("Success")
      login_success_screen.geometry("150x100")
      Label(login_success_screen, text="Login Success").pack()
      Button(login_success_screen, text="OK", command=delete_login_success).pack()
  
  def password_not_recognised():
      global password_not_recog_screen
      password_not_recog_screen = Toplevel(login_screen)
      password_not_recog_screen.title("Success")
      password_not_recog_screen.geometry("150x100")
      Label(password_not_recog_screen, text="Invalid Password ").pack()
      Button(password_not_recog_screen, text="OK", command=delete_password_not_recognised).pack()
  
  
  def user_not_found():
      global user_not_found_screen
      user_not_found_screen = Toplevel(login_screen)
      user_not_found_screen.title("Success")
      user_not_found_screen.geometry("150x100")
      Label(user_not_found_screen, text="User Not Found").pack()
      Button(user_not_found_screen, text="OK", command=delete_user_not_found_screen).pack()
  
  </code></pre>
  
  <p>when logging in with an incorrect password it should run the function 'password_not_recognised'</p>
  
  <p>when logging in with details not in the database it should run 'user_not_found'</p>
  
  <p>and when details are correct it should run login_success ()</p>