Good evening all,
I have a question regarding allowing each user id upload a profile picture. I'm building a dynamic website that allows users to register and have their own profile. In their profile, they can upload a profile picture. I have many tables in my database, including a table for registration which has the user_id as the primary key, and a table for uploading profile pictures which has picture_id as the primary key and user_id as the foreign key.
Now here's the problem: When I login, the user_id is inserted into the database, but when I go to the profile page to upload a picture, I get a "user id does not exist" error (I added that error message). Then I'd have to go to the profile picture table and manually add the user_id to the table and then the profile picture gets uploaded.
So, my question is, when a user logs in and the user_id(primary key) in the registration table is inserted, is there a way to also update and insert that same id in the user_id(foreign key) in the profile picture table without doing it manually? So that each user can have his own profile picture.
PS: I'm not uploading the pictures themselves into the database, i'm inserting the path of the image into the database.
I appreciate any help.
Thanks!