Oop login code | Sololearn: Learn to code for FREE!

0

Oop login code

Hi, I'm looking to create a oop work management tool, my first screen is the login but I've hit a block on how should i start this. Any help please?

11/5/2021 10:28:22 PM

Shan Raza

10 Answers

New Answer

+3

oop is about making objects so you could start with deciding what classes you are going to make and for what purpose they will be made for.

+1

You'd need to go through the filehandling section here, but its fairly simple. The hard part is writing the data so its easy to read. Cause you'd have to code that too

0

Thanks, in this scenario my class would be just be User. class User(): def __init__(self, username, password, email): self.username = username self.password = password self.email = email def login(self, username, password): self.username = input("Enter username: ") self.password = input("Enter password: ") with open("register.txt", "r", encoding=utf-8) as file: if username == username and password == password: print("login successful!") Would this be sufficient?

0

Not really, cause it seems like you want to keep a database text file of usernames and passwords. But your code opens up a file to read it and does nothing with it. Then it compares 2 strings against themselves so it will ALWAYS print out "login successful"

0

How would i give an error if either does not match with the name and passwords stored in a file?

0

How would i save the details to a new file?

0

I've gone through the sections and whilst i understand it, when it comes to writing the code i seem to get stuck. This had been the case for every aspect of my project as well.

0

trial and error is your friend! Also try writing out some code and then bring that to us

0

Hi guys, i manged to create a screen and connect to sqlite3 db but when i run the code the text is not visble in the gui screen and typerror. missing 1 required positional argumemt. any advise? i didn't include an __init__ method, could this be the issue?

0

it's very possible you didn't include the "self" parameter in your __init__ definition