I've been working on the register part of the finance problem and I think I have most of it but I really don't understand how to do the SQL parts of it. I need to learn how to store the username and password in the database. Any advice on how to get started doing this would be appreciated. Thanks
1 Answer
You won't store the password, but the hashed (and salted) password. That way, even if someone gains access to your database, they won't know the password, at least not immediately. They will have other interesting data, though.
My user table contains just a unique id (autogenerated), a unique user name, the hashed password, and cash value (has default value). So after checking the user for being a duplicate (by doing a SELECT with the desired user name, and ensuring the returned list of records is empty) I do an INSERT for just the name and password, the other two fields are inserted automatically.
Please use the db.execute("... :somename ...", somename=somevalue)
syntax rather than db.execute("... " + somevalue + " ...")
(I did the latter in my early SQL code, and it's dangerous stuff allowing for SQL injections, ask Bobby Tables)