So i am creating a account login system which searches a database for a username (and its relevant password) and, if found, will log the user on.
This is what the csv file currently looks like
['dom', 'enter password']
This is written in one field (on an excel spreadsheet), and was written to the file when the user registered. However when I try to log on, the program will only log on if that is what is entered in the field, when I would like it to log on when dom is entered.
Here is the code which reads the csv file to see if the username/password is found on the file:
def Get_Details():user_namev2=user_name.get().lower() #Make it so entry box goes red if passwords password is incorrect, and red if username is incorrect/not faultuser_passwordv2=user_password.get().lower()with open ('Accounts.csv', 'r') as Account_file:reader = csv.reader(Account_file)for row in reader:for field in row:if field == user_namev2:print ("In file")
Here is how the username and password get written to the csv file upon registering an account.
if re.match(user_password2v2, user_passwordv2):print("Passwords do match")user_info = []user_info.append(user_namev2)user_info.append(user_passwordv2)with open ('Accounts.csv', 'a') as Account_file:writer = csv.writer(Account_file)writer.writerow([user_info])Bottom()
Any ideas on how i can search the csv file so that only a certain part of the string is searched and matched with user_namev2