How to correctly reference a PHP session variable in a SQL statement

liro

New Member
I have seen a few postings about this online, but none of the recommendations have worked in my case. My situation is simple.. a user logs into a php form, authenticates with the backend mysql table, starts the session, carries them to the next page. What I am wanting to do is bring out the rest of that users data into textboxes, tables, whatever. However, the only way I have been introduced to doing this is by referencing the session variable. What I have so far is below and I have tried many variations of it, but nothing seems to work (i.e. no values, page doesn't load, etc). I am open to other options though. Thanks all. \[code\]$query = "SELECT * FROM users WHERE username = '{$_SESSION['user']}'"\[/code\]
 
Back
Top