kasitzboym Posted June 14, 2010 Share Posted June 14, 2010 Hi everyone... I have kind of a complicated problem that i hope someone can help me with. I have a registration section of my site already up and running... i am trying to create another section of my site so that the user that is logged in can create a posting and link it to their username.... currently i have two tables in a mysql database one named (users) to hold the username and password that i want to pull the username from and another that holds the information for posting called (laf).... My basic question is how can i pull the username from the (users) database and place it into the (laf) database when they post? This is a really hard thing to explain i know, if anyone can help or needs any more information let me know... Thanks in advance Quote Link to comment Share on other sites More sharing options...
Rustywolf Posted June 14, 2010 Share Posted June 14, 2010 if you set the username as $_SESSION['user'] then you could use something like this: mysql_query("INSERT INTO laf (username, data) VALUES('" . $_SESSION['user'] . "', '" . $data. "'); then list like: mysql_query("SELECT * FROM laf WHERE username='" . $username . "'"); Quote Link to comment Share on other sites More sharing options...
kasitzboym Posted June 14, 2010 Author Share Posted June 14, 2010 Sorry i dont quite understand... This is getting a little more advanced than im used to do you think you might be able to explain it a little to me please? Quote Link to comment Share on other sites More sharing options...
isedeasy Posted June 14, 2010 Share Posted June 14, 2010 edit - meh I read the question wrong... When the user logs in you need to set a session variable containing their id/username. you can then use this value in your mysql where clause. Quote Link to comment Share on other sites More sharing options...
kasitzboym Posted June 14, 2010 Author Share Posted June 14, 2010 Thanks for the advice... Ive looked over the Session commands but dont quite understand how they work... could someone help me to understand how to pull that username from the current session Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.