Advertisement
Guest User

code

a guest
Oct 26th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. def startup():
  2. with open('Admin.txt', 'w+') as q:
  3. q.write('Admin : Password')
  4. with open("Admin.txt", 'a+') as r:
  5. r.read()
  6. print ("Admin Username and Password has been set")
  7. home()
  8.  
  9. def home():
  10. print("Do you want to create a new user (guest) or Log In?")
  11. log_user = input()
  12. if log_user == "Log In":
  13. login()
  14. elif log_user == "new user":
  15. new_user_maker()
  16. else:
  17. print ("Sorry that was not a valid option please try again")
  18. home()
  19.  
  20. def new_user_maker():
  21. print("What is your name?")
  22. name = input()
  23. print("What is your age?")
  24. age = input()
  25. new_guest_user = name[0:3] + age
  26. print("What do you want as a password?")
  27. new_guest_pass = input()
  28. with open(new_guest_user + '.db', 'w') as w:
  29. w.write(new_guest_user + " : " + new_guest_pass)
  30. login()
  31.  
  32. def login():
  33. print("You will now log in")
  34. print("Are you a Admin or Guest? ")
  35. user_type = input()
  36. if user_type == 'Admin':
  37. Admin_login()
  38. elif user_type == 'Guest':
  39. Guest_login()
  40. else:
  41. print("That is not an valid option sorry, please specify 'Admin' or 'Guest'")
  42. login()
  43.  
  44. def Admin_login():
  45. print("You chose to be an admin")
  46. print("Please input your username: ")
  47. Admin_Name = input()
  48. print("Please input your password: ")
  49. Admin_Password = input()
  50. try:
  51. filename = Admin_Name + ".txt"
  52. with open(filename, 'r') as checking_user_and_pass:
  53. Admin_correct = checking_user_and_pass.read()
  54. if Admin_correct == Admin_Name + " : " + Admin_Password:
  55. print("You are now logged in as an admin")
  56. else:
  57. print ('Incorrect Username or Password')
  58. print ("Do you want to Try Again or log in as a different user")
  59. option = input ()
  60. if option == 'Try Again':
  61. Admin_login()
  62. except:
  63. print ('Incorrect Username or Password')
  64. print ("Do you want to Try Again or Log In as a different user")
  65. option = input()
  66. if option == "Try Again":
  67. Admin_login()
  68. else:
  69. print("You chose to be a different user")
  70. login()
  71.  
  72. def Guest_login():
  73. print("You chose to be a guest")
  74. print("Please input your username: ")
  75. Guest_Name = input()
  76. print("Please input your password: ")
  77. Guest_Password = input()
  78. try:
  79. filename = Guest_Name + ".db"
  80. with open(filename, 'r') as checking_user_and_pass:
  81. Guest_correct = checking_user_and_pass.read()
  82. if Guest_correct == Guest_Name + " : " + Guest_Password:
  83. print("You are now logged in as", Guest_Name)
  84. else:
  85. print ('Incorrect Username or Password')
  86. print ("Do you want to Try Again or log in as a different user")
  87. option = input ()
  88. if option == 'Try Again':
  89. Guest_login()
  90. except:
  91. print ('Incorrect Username or Password')
  92. print ("Do you want to Try Again or Log In as a different user")
  93. option = input()
  94. if option == "Try Again":
  95. Guest_login()
  96. else:
  97. print("You chose to be a different user")
  98. login()
  99.  
  100. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement