Jump to content

Display Logged In User Information


Xeven

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.