Skip to content
Advertisement

How to retrieve the id stored in a session?

I have a form that allows you to register and log in and a reservation form that allows you to choose a date and time. I would like to be able to retrieve the user id and in my ‘Bookings’ table in the ‘user_id’ field.

My Database looks like this :

My Database

And the form that fills my booking table :

In my ‘member’ table the id is stored like this:

Advertisement

Answer

you’ve not written code to add user id, then it’s not gonna enter in db automagically.

First of all start session with this session_start();

Then change your code like following:

Here in insert query I’ve added user_id field and given it’s value in bind statement.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement