Created
January 20, 2016 12:42
-
-
Save kenbellows/c0f7d4f444e9aa359388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login(): | |
print('Welcome to the eHealth program, please sign in') | |
with open ('users.csv') as csvfile: | |
database = csv.DictReader(csvfile) | |
loggedin = False | |
while loggedin != True: | |
Username = input('Fill in your username: ') | |
Password = input('Fill in your password: ') | |
for row in database: | |
Username_File = row['username'] | |
Password_File = row['password'] | |
Function_File = row['function'] | |
if Username_File == Username and Password_File == Password and Function_File == 'patient': | |
loggedin = True | |
print('Succesfully logged in as a patient.') | |
#patientmenu() # we will add this later on | |
elif Username_File == Username and Password_File == Password and Function_File == 'arts': | |
loggedin = True | |
print('Succesfully logged in as a doctor.') | |
#artsmenu() # we will add this later on | |
elif Username_File != Username and Password_File == Password: | |
#loggedin = False | |
print('Failed to sign in, wrong username.') | |
elif Username_File == Username and Password_File != Password: | |
#loggedin = False | |
print('Failed to sign in, wrong password.') | |
elif Username_File != Username and Password_File != Password: | |
#loggedin = False | |
print('Failed to sign in, wrong username and password.') | |
else: | |
print('Error 404, Login Not Found') | |
# ---- Main ---- # | |
login() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For: http://stackoverflow.com/questions/34899153/python-username-and-password-login-while-and-for-loop