SHARE
TWEET

Untitled

a guest Apr 2nd, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter
  2. from tkinter import *
  3. from tkinter import ttk
  4. def checkusername(user_name):
  5.     for line in open("accountfile.txt", "r").readlines():  # Read the lines
  6.         login_info = line.split()  # Split on the space, and store the results in a list of two strings
  7.         if user_name == login_info[0]:
  8.             print("Correct credentials!")
  9.             return False
  10. def register():
  11.     file = open("accountfile.txt", "a")
  12.     username = input("Enter User Name:")
  13.     print(checkusername(username))
  14.     while (checkusername(username) == False):
  15.         username = input("Already exisit, Enter User Name:")
  16.  
  17.     file.write(username)
  18.     file.write(" ")
  19.     password = input("Enter Password: ")
  20.     file.write(password)
  21.     file.write("\n")
  22.     file.close()
  23.     if login():
  24.         print("You are now logged in...")
  25.     else:
  26.         print("You aren't logged in!")
  27.  
  28.  
  29. def login():
  30.     username = input("Please enter your username")
  31.     password = input("Please enter your password")
  32.     for line in open("accountfile.txt", "r").readlines():  # Read the lines
  33.         login_info = line.split()  # Split on the space, and store the results in a list of two strings
  34.         if username == login_info[0] and password == login_info[1]:
  35.             print("Correct credentials!")
  36.             return True
  37.     print("Incorrect credentials.")
  38.     return False
  39.  
  40. register()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top