I am currently doing my NEA and I am having problems with the login stage. This is my registration code:
def login_create():
import pickle
import os
new_login_filename = 'new_login.dat'
login_list = []
if os.path.exists(new_login_filename):
yeet = open(new_login_filename,'rb')
pickle.load(yeet)
new_login = username, password
login_list.append(new_login)
with open(new_login_filename,'ab') as wfp:
pickle.dump(login_list, wfp)
with open(new_login_filename,'rb') as rfp:
login_list = pickle.load(rfp)
It saves the registered username and password into a .dat file called new_login. I can't seem to work out how to get the login to work though. This is what I currently have:
def login():
import pickle
usernameV = False
passwordV = False
username_login = input("Enter your Username")
password_login = input("Enter your Password")
f = open("new_login.dat","rb")
for i in range(len(new_login)):
if username_login in new_login[i][0]:
print("Valid Username")
usernameV == True
elif password_login in new_login[0][i]:
print("Valid Password")
passwordV == True
elif usernameV == True and passwordV == True:
valid = True
return valid
f.close()
I get errors with new_login not being defined and then it just doesn't work at all. Any help will be greatly appreciated as I have been trying to work this out and I have been looking everywhere and nothing I do seems to work.