I have a booking system, in which once a user books a flight, their details are sent to a mySQL table called OABS_customers.
It’s structure is the following:
Name Type(Length) Null Default name varchar(60) No noname address1 varchar(60) No noaddress address2 varchar(60) No noaddress2 county varchar(60) No nocounty postcode varchar(32) No nopostcode customer tinyint(4) No seats varchar(11) No 0 number tinyint(4) No 0 class varchar(11) No noclass username varchar(60) No nousername
Now, my script adds all of the details with no problem – except for one column – the username column. I’m using this code: $query = "INSERT INTO OABS_customers (username) VALUES ('$user')"; (provided kindly by eggyal) to take the logged in users name (which is stored in the cookie ID_my_site and $user = $_COOKIE['ID_my_site'] – and I have tested that and it does contain the username of the logged in user) and add it into the username table, however this doesn’t seem to work, and it instead displays the default value of nousername.
If anyone could help amend this issue I would greatly appreciate it.
You need to modify you login mechanism to track the user ID for the session.
Store the ID in memory or in a cookie.
Once you can store the user id now you can save it to the DB.