This question already has an answer here:
(somewhat new to this) I've been coding this small little application with a login system and just some small user stats later on. The multi user system seems to work fine when it comes to creation and logging in if you are using the correct username and password, however, if I use the username from one account and the password from another, it spews out code from different lines. Image of such lines
This is the code for the login. It's not the cleanest but I've been trying to get it to actually work before I do some cleaning up. If cleaning is necessary for it to work, then I deserve that. If its a simple error I have overlooked, please excuse me for doing so. Atleast I will learn from it.
Login:
while c == 0:
print ("Please login!") ## This is indented here, it wont show up here :/
while d == 0:
usernametest = "";
usernametest = input("Please enter your username: ")
if username.strip() != "": ## first user signed up
if username2.strip() != "": ## 2 users signed up
if username3.strip() != "": ## 3 users signed up
if usernametest != username or username2 or username3:
print("Username not recognised!")
else:
if usernametest == username3: #checking user 3 login
print("Username accepted!")
passwordtest = input("Please enter your password")
if passwordtest != password3:
print("Password incorrect, please try again")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = 1;
useaccount = 3;
break
elif usernametest == username2: #checking user 2 login
print("Username accepted!")
passwordtest = input("Please enter your password: ")
if passwordtest != password2:
print("Password incorrect, please try again!")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = 1;
useaccount = 2;
break
elif usernametest == username: # checking user 1 login
print("Username accepted!")
passwordtest = input("Please enter your password: ")
if passwordtest != password:
print("Password incorrect, please try again!")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = 1;
useaccount = 1;
break
if usernametest != username or username2: #checking user 2 login
print("Username not recognised!")
else:
if usernametest == username2:
print("Username accepted!")
passwordtest = input("Please enter your password: ")
if passwordtest != password2:
print("Password incorrect, please try again!")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = l;
useaccount = 2;
break
elif usernametest == username: # checking user 1 login
print("Username accepted!")
passwordtest = input("Please enter your password: ")
if passwordtest != password:
print("Password incorrect, please try again!")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = 1;
useaccount = 1;
break
if usernametest != username: # checking user 1 login
print("Username not recognised!")
else:
print("Username accepted!")
passwordtest = input("Please enter your password: ")
if passwordtest != password:
print("Password incorrect, please try again!")
else:
print("Password Accepted!")
print("------------------")
print("Successfully logged in!")
d = 1;
c = 1;
useaccount = 1;
break
Aucun commentaire:
Enregistrer un commentaire