Python Forum
Creating a Login System Using Python- HELP - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Creating a Login System Using Python- HELP (/thread-6799.html)



Creating a Login System Using Python- HELP - tesilstudent112 - Dec-08-2017

Hey everyone. I am trying to create a login system for a user in python- this is my code so far(bare in mind i'm basically a beginner so if you could give me some helpful tips that'd be great).

What I struggle to do is:
1) Assuming that the user has already signed up before, how do I get my program to remember their details from last time allowing them to log in?
2) I need some validation help, e.g. whether their password is valid, their age and name etc
I'm sure that there are many other problems, like making my code as efficient as possible. Also, I'm learning about functions and I already know how to do loops although they are not needed here? If anyone can help ASAP or maybe even become my teacher or something, i'd love you forever. Thank you in advance.

users = {"username, ": "password"}

user_choice = raw_input("Do you want to: \n a. Sign in \n b. Sign up?\n c. Quit \n")


if user_choice == "b" or "r":
print("Please enter the following details: \n")
name = raw_input("Name : ")
age = raw_input("Age: ")
yearGroup = raw_input("Year Group: ")
username= name[0:3] + age
if username in users:
print("This username already exists! ")
else:
print("Welcome {} ! Your username is {} - now press enter to create your password").format(name, username)
password = raw_input("Password: ")
password_confirmation = raw_input("Confirm password: ")
users = username + password
if password != password_confirmation:
print("please try again")
else:
print("Sign up complete. \n")
print(users)
user_choice = raw_input("Press 'a' to sign in or 'c' to quit: ")

if user_choice == "a":
print("Press enter to write your details: ")
user_login =raw_input("Username: ")
if user_login not in users:
print("Invalid login. ")
user_choice == raw_input("\nPlease press 'r' to register or 'c' to quit. ")
else:
user_password = raw_input("Password: ")
if user_password in users:
print("\nYou have succesfully logged in!")
else:
print("Incorrect password.")