Xeven Posted February 16, 2008 Share Posted February 16, 2008 Thanks to the guys that gave me a hand with my last problem I had with some PHP stuff. I managed to get that working and all is good. I have hit another problem however. I have a site which lets users register and login to. What I need to be able to do is store data in a database which applies to each user specific personal page. So for example an inbox. Once the user has logged in, the user is only able to see data which is for his user credentials. Is this going to be possible using PHP? I thought it would be possible using sessions once the user has logged in, but I am not too sure how to go about doing this. Any ideas or feedback would be great. Thanks Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 16, 2008 Share Posted February 16, 2008 If you're wanting to do an inbox (I'm assuming for users to be able to send messages to each other). You could have a "messages" table or something similar. In the table you can have fields like: id to_id from_id title content id would be an auto_increment field to_id is the user id of the person it's sent to from_id is the user id of the person it's sent from title and content are pretty easy to guess So on the users inbox page, you could retrieve all messages where the to_id is equal to their user id Hopefully that's what you were wanting! Quote Link to comment Share on other sites More sharing options...
Xeven Posted February 16, 2008 Author Share Posted February 16, 2008 Hi and thanks for the reply. The inbox is as much to send messages to and from each other. Its just to be able to pull information from a database for which ever user has logged in. So I have a table which the data is stored into and there is a field which is called "user". Now what I am trying to do is for example I have the user "Bill" logged in. When Bill goes to the inbox page he can view the data stored on the database which in the user field has "Bill". This I can do as it is just using a standard mysql query to pull the information. My only issue is that there will be multiple user accounts logging in. So I need some way to make the page dynamic, so when "Jane" logs in, and she goes to the inbox page she can only see what is stored in the database field for Jane. I have sessions working fine, would it be possible to use the session to call the data for whoever is logged in? Hope that is in some way understandable. Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 16, 2008 Share Posted February 16, 2008 Of course, just pass the session info to the MySQL query. Although I'd suggest storing the User ID in the session rather than their user name. For example you could do this: $query = "SELECT * FROM users WHERE id = "'$_SESSION['user_id']."'"; Quote Link to comment Share on other sites More sharing options...
Xeven Posted February 17, 2008 Author Share Posted February 17, 2008 Amazing! Thanks for your help, worked like a treat. This forum has been great so far! Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 17, 2008 Share Posted February 17, 2008 No problem, although I noticed a typo in my previous post (I put "' rather than '") but I'm going to assume you figured that one out Quote Link to comment Share on other sites More sharing options...
Xeven Posted February 17, 2008 Author Share Posted February 17, 2008 Hehe, yeah I did pick up on that, there was also another thing which needed to be added which was the ('".$_SESSION['sessioname']."'"). This was my query in the end: $sql = "SELECT * FROM upload WHERE user = '".$_SESSION['sessioname']."'"; $result = mysql_query($sql,$connect) or die (mysql_error()); Thanks again for your help 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.