Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.81 KB | None | 0 0
  1. import sys
  2.  
  3. def loginstart():
  4.     print("Welcome To The Login!")
  5.     p = open("password.txt","r")
  6.     actualpassword = p.read()
  7.     p.close()
  8.  
  9.     u = open("username.txt","r")
  10.     actualusername = u.read()
  11.     u.close()
  12.  
  13.     if actualusername == "" or actualpassword == "":
  14.         print("We Have Detected That You Have Not Set Any Login Details.")
  15.         newlogin()
  16.  
  17.     else:
  18.         loginmatch()
  19.  
  20.  
  21.  
  22. #---------------------------------------------------
  23. def newlogin():
  24.     passwordfile = open("password.txt","w")
  25.     passwordfile.write("")
  26.     passwordfile.close
  27.    
  28.     usernamefile = open("username.txt","w")
  29.     usernamefile.write("")
  30.     usernamefile.close
  31.    
  32.     usernameentry = input("Please Enter A New Username: ")
  33.     passwordentry = input("Please Enter A New Password: ")
  34.     print("Please restart the program in order to login.")
  35.    
  36.  
  37.     passwordfile = open("password.txt","w")
  38.     passwordfile.write(passwordentry)
  39.     passwordfile.close
  40.    
  41.     usernamefile = open("username.txt","w")
  42.     usernamefile.write(usernameentry)
  43.     usernamefile.close
  44.  
  45.  
  46.  
  47. #-------------------------------------------------------
  48.  
  49. def loginmatch():
  50.  
  51.     p = open("password.txt","r")
  52.     actualpassword = p.read()
  53.     p.close()
  54.  
  55.     u = open("username.txt","r")
  56.     actualusername = u.read()
  57.     u.close()
  58.  
  59.     ihopethisworks = True
  60.  
  61.     while ihopethisworks == True:
  62.         userusername = input("Enter Username Here: ")
  63.         userpass = input("Enter Password Here: ")
  64.  
  65.         if userusername != actualusername:
  66.             print("Incorrect Username.")
  67.             ihopethisworks = True
  68.  
  69.         if userpass != actualpassword:
  70.             print ("Incorrect Password.")
  71.             ihopethisworks = True
  72.  
  73.         if userpass == actualpassword and userusername == actualusername:
  74.             print ("Login Details Accepted.")
  75.             ihopethisworks = False
  76.             menusystem()
  77.  
  78. #-----------------------------------------------------------------------------------    
  79.    
  80.  
  81. def menusystem():
  82.         menurepeat = True
  83.         while menurepeat == True:
  84.             print("Welcome To The Menu System!")
  85.             print("Where would you like to go?")
  86.             print("Enter '1' to go to the Student Information Section.")
  87.             print("Enter '2' to go to the Report Menu Section.")
  88.             print("Enter '3' to go to change your login details.")
  89.             print("Enter '4' to logout.")
  90.             menuinput = input("Enter Here: ")
  91.             if menuinput == "1":
  92.                 studentsinformation()
  93.                 menurepeat = False
  94.             elif menuinput == "2":
  95.                 reportmenu()
  96.                 menurepeat = False
  97.             elif menuinput == "3":
  98.                 print("Please confirm your current login details.")
  99.                 logincheck()
  100.                 menurepeat = False
  101.             elif menuinput == "4":
  102.                 print("You have logged out and are being returned to the login!")
  103.                 loginstart()
  104.                 menurepeat = False
  105.        
  106.        
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. #------------------------------------------------------------------------------------
  124.  
  125. def logincheck():
  126.     p = open("password.txt","r")
  127.     actualpassword = p.read()
  128.     p.close()
  129.  
  130.     u = open("username.txt","r")
  131.     actualusername = u.read()
  132.     u.close()
  133.  
  134.     ihopethisworks = True
  135.  
  136.     while ihopethisworks == True:
  137.         userusername = input("Enter Username Here: ")
  138.         userpass = input("Enter Password Here: ")
  139.  
  140.         if userusername != actualusername:
  141.             print("Incorrect Username.")
  142.             ihopethisworks = True
  143.  
  144.         if userpass != actualpassword:
  145.             print ("Incorrect Password.")
  146.             ihopethisworks = True
  147.  
  148.         if userpass == actualpassword and userusername == actualusername:
  149.             print ("Login Details Accepted.")
  150.             ihopethisworks = False
  151.             newlogin()
  152.    
  153.  
  154.  
  155.  
  156. def studentsinformation():
  157.     studentinforepeat = True
  158.     while studentinforepeat == True:
  159.         print("Welcome to the Student Information Section.")
  160.         print("Enter '1' to Enter New Students Information.")
  161.         print("Enter '2' to Read Student Information.")
  162.         print("Enter '3' to Go Back.")
  163.         studentinfoinput = input("Enter Here: ")
  164.         if studentinfoinput == "1":
  165.             enterstudents()
  166.             studentinforepeat = False
  167.         elif studentinfoinput == "2":
  168.             studentidretrieve()
  169.             studentinforepeat = False
  170.         elif studentinfoinput == "3":
  171.             menusystem()
  172.        
  173.  
  174. def enterstudents():
  175.     studentID = input("Please enter the students ID: ")
  176.     studentforename = input("Please enter the students forename: ")
  177.     studentsurname = input("Please enter the students surname: ")
  178.     studentdob = input("Please enter the students date of birth: ")
  179.     studentaddress = input("Please enter the students address: ")
  180.     studentphonenumber = input("Please enter the students home phone number: ")
  181.     studentgender = input("Please enter the students gender: ")
  182.     studenttutorgroup = input("Please enter the students tutor group: ")
  183.     studentemail = input("Please enter the students email address: ")
  184.  
  185.     studentfilename = studentID + " information.txt"
  186.     es = open(studentfilename, "w+")
  187.     es.write("Student ID: ")
  188.     es.write(studentID)
  189.     es.write("\n")
  190.     es.write("Forename: ")
  191.     es.write(studentforename)
  192.     es.write("\n")
  193.     es.write("Surname: ")
  194.     es.write(studentsurname)
  195.     es.write("\n")
  196.     es.write("Date of Birth: ")
  197.     es.write(studentdob)
  198.     es.write("\n")
  199.     es.write("Address: ")
  200.     es.write(studentaddress)
  201.     es.write("\n")
  202.     es.write("Phone Number: ")
  203.     es.write(studentphonenumber)
  204.     es.write("\n")
  205.     es.write("Gender: ")
  206.     es.write(studentgender)
  207.     es.write("\n")
  208.     es.write("Tutor Group: ")
  209.     es.write(studenttutorgroup)
  210.     es.write("\n")
  211.     es.write("Email: ")
  212.     es.write(studentemail)
  213.     es.close()
  214.  
  215.     print("Successfully entered student information.")
  216.  
  217.     studentsinformation()
  218.    
  219.    
  220.  
  221.                        
  222.    
  223.    
  224.  
  225. def logout():
  226.     print("Welcome to the logout function!")
  227.  
  228. def studentidretrieve():
  229.     studentidretrieve = input("Please input the students ID.")
  230.     studentfilenameretrieve = studentidretrieve + " information.txt"
  231.     esr = open(studentfilenameretrieve,'r')
  232.     studentinfo = esr.read()
  233.     print(studentinfo)
  234.     esr.close()
  235.  
  236.    
  237.  
  238.  
  239.  
  240.  
  241.  
  242. def reportmenu():
  243.     print("Welcome to the report menu function!")
  244.  
  245. def report1():
  246.     print("Welcome to report 1!")
  247.  
  248. def report2():
  249.     print("Welcome to report 2!")
  250.  
  251. def report3():
  252.     print("Welcome to report 3!")
  253.  
  254.  
  255.  
  256. #----------------------------------------------------------------------------------
  257.  
  258. loginstart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement