Inserting sales data into my sales table

Please can I have some advice, I have two tables in my database Users and Sales, I have successfully created a login system that creates a user and inserts user details (id, username, hash, salt) into the User table.

My question is best way to insert and update sales?
Do i when inserting a new user into Users I would also Insert their username into the Sales tables, and use update scripts when adding new sales?

I am thinking to have username and then all my sales types in the Sales table.

I would suggest you fix your login code first. Use password_hash and password_verify.

As to your question, use the user_id, NOT the username to link tables.

Separating the personal/contact info from all sales info would be best IMHO… (of course some sort of user ID in each sales transaction to match all sales with their user.)

I would use more than just a username to be associated with the transaction, a unique user ID number that is assigned once they ‘sign-up’ as well…

Sponsor our Newsletter | Privacy Policy | Terms of Service