Advertisement
Guest User

Untitled

a guest
Feb 13th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. # Some variable declaration
  2. userFound = False
  3. ind = 0
  4. logged_in = False
  5. # Get user list from txt file
  6. usertxt = open('users.txt', 'r')
  7. userlist = usertxt.read().split('\n')
  8. usertxt.close()
  9. # Get username from user, check if valid
  10. user = raw_input('Username: ')
  11. for line in userlist:
  12.     if user in line:
  13.         userFound = True
  14.         ind = userlist.index(line)
  15.         break
  16. # Get pass list from txt file
  17. passtxt = open('pass.txt', 'r')
  18. passlist = passtxt.read().split('\n')
  19. passtxt.close()
  20. pass_ = raw_input('Password: ')
  21. # Confirms if password is good or not, logs in if good
  22. if pass_ == passlist[ind]:
  23.     logged_in = True
  24.  
  25. if logged_in:
  26.     print "Log in succesful. Welcome %s." % user
  27. else:
  28.     print "Log in failed. Username or password incorrect."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement