Geocrack

adminlog_fixed

Jul 2nd, 2022 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.29 KB | None | 0 0
  1. #I defined menu
  2.  
  3. #I defined menu for Admin
  4.  
  5. #I declared the user name and password for Admin
  6.  
  7. def menu():
  8.  
  9.     print("[1] Admin")
  10.  
  11.     print("[2] Guest")
  12.  
  13.     print("[3] Customer")
  14.  
  15.     print("[0] Exit the system.")
  16.  
  17.  
  18. def admin_menu():
  19.     print("[10} Sign out")
  20.  
  21.     print("[11] Upload med")
  22.  
  23.     print("[12] View med")
  24.  
  25.     print("[13] Update med")
  26.  
  27.     print("[14] Delete med")
  28.  
  29.     print("[15] Search med")
  30.  
  31.     print("[16] View order")
  32.  
  33.     print("[17] Search order")
  34.  
  35.     print("[18] Exit the system.")
  36.  
  37.  
  38. def admin_commands(op):
  39.     print("-"*10)
  40.     if op ==11:
  41.         print("Upload")
  42.     elif op ==12:
  43.         print("View upload")
  44.     elif op ==13:
  45.         print("Update")
  46.     elif op ==14:
  47.         print("Delete")
  48.     elif op ==15:
  49.         print("Search")
  50.     elif op ==16:
  51.         print("View order")
  52.     elif op ==17:
  53.         print("Search order")
  54.     elif op ==18:
  55.         print("Exit to main menu")
  56.     else:
  57.         print("Invalid option.")
  58.     print("-"*10)
  59.  
  60.     #I defined the adminlog
  61.  
  62.  
  63. def adminlog(username, password):
  64.     print("\nYou are directed to Admin")
  65.  
  66.     print("\nPlease enter your username and password.")
  67.  
  68.     name=input("Username:")
  69.  
  70.     passw=input("Password:")
  71.  
  72.     if name==username:  
  73.  
  74.         if passw==password:
  75.  
  76.             print("\nWelcome", username)
  77.             while True:
  78.                 admin_menu()
  79.                 op = int(input("Enter your option: "))
  80.                 if op ==10:
  81.                     return
  82.                 admin_commands(op)
  83.     else:
  84.         print ("\nThe username or password you have entered is incorrect")
  85.  
  86.  
  87. #Called menu so user chooses the options provided
  88.  
  89. #when user chooses option 1 he gets directed to option1() --> adminlog()
  90. def main():
  91.     username = "joe"
  92.     option = None
  93.     password = "joe"
  94.  
  95.     while option !=0:
  96.         menu()
  97.         option = int(input("Enter your option: "))
  98.  
  99.         if option ==1:
  100.             adminlog(username, password)
  101.         elif option ==2:
  102.             print("You are directed to Guest")
  103.         elif option ==3:
  104.             print("You are directed to Customer")
  105.         else:
  106.             print("Invalid option.")
  107.  
  108.     print()
  109.     print("Thank you for using this program. Goodbye.")
  110.  
  111.  
  112. if __name__ == '__main__':
  113.     main()
Advertisement
Add Comment
Please, Sign In to add comment