Advertisement
Guest User

Shoaib code

a guest
Oct 26th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 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 username do you want?")
  22. new_guest_user = input()
  23. print("What do you want as a password?")
  24. new_guest_pass = input()
  25. with open(new_guest_user + '.db', 'w') as w:
  26. w.write(new_guest_user + " : " + new_guest_pass)
  27. login()
  28.  
  29. def login():
  30. print("You will now log in")
  31. print("Are you a Admin or Guest? ")
  32. user_type = input()
  33. if user_type == 'Admin':
  34. Admin_login()
  35. elif user_type == 'Guest':
  36. Guest_login()
  37. else:
  38. print("That is not an valid option sorry, please specify 'Admin' or 'Guest'")
  39. login()
  40.  
  41. def Admin_login():
  42. print("You chose to be an admin")
  43. print("Please input your username: ")
  44. Admin_Name = input()
  45. print("Please input your password: ")
  46. Admin_Password = input()
  47. try:
  48. filename = Admin_Name + ".txt"
  49. with open(filename, 'r') as checking_user_and_pass:
  50. Admin_correct = checking_user_and_pass.read()
  51. if Admin_correct == Admin_Name + " : " + Admin_Password:
  52. print("You are now logged in as an admin")
  53. else:
  54. print ('Incorrect Username or Password')
  55. print ("Do you want to Try Again or log in as a different user")
  56. option = input ()
  57. if option == 'Try Again':
  58. Admin_login()
  59. except:
  60. print ('Incorrect Username or Password')
  61. print ("Do you want to Try Again or Log In as a different user")
  62. option = input()
  63. if option == "Try Again":
  64. Admin_login()
  65. else:
  66. print("You chose to be a different user")
  67. login()
  68.  
  69. def Guest_login():
  70. print("You chose to be a guest")
  71. print("Please input your username: ")
  72. Guest_Name = input()
  73. print("Please input your password: ")
  74. Guest_Password = input()
  75. try:
  76. filename = Guest_Name + ".db"
  77. with open(filename, 'r') as checking_user_and_pass:
  78. Guest_correct = checking_user_and_pass.read()
  79. if Guest_correct == Guest_Name + " : " + Guest_Password:
  80. print("You are now logged in as", Guest_Name)
  81. else:
  82. print ('Incorrect Username or Password')
  83. print ("Do you want to Try Again or log in as a different user")
  84. option = input ()
  85. if option == 'Try Again':
  86. Guest_login()
  87. except:
  88. print ('Incorrect Username or Password')
  89. print ("Do you want to Try Again or Log In as a different user")
  90. option = input()
  91. if option == "Try Again":
  92. Guest_login()
  93. else:
  94. print("You chose to be a different user")
  95. login()
  96.  
  97. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement