Jump to content

How to Display LOGGED IN AS: USER NAME on index page


Recommended Posts

Can be done many ways, depends how you're logging in the user; generally i use sessions, you could use cookies i guess.

 

Using sessions you'll need an login script. That will validate the user, and store their information in session variables.

 

In your index page, you then will need to call up the session value that you want to display.

 

Hope that helps.

 

Chris.

 

 

[!--quoteo(post=322982:date=Nov 29 2005, 07:41 AM:name=Crash Override)--][div class=\'quotetop\']QUOTE(Crash Override @ Nov 29 2005, 07:41 AM) 322982[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I would like to know how to display such as is on this page:

 

LOGGED IN AS: CRASH OVERRIDE

 

I am sure this is easy for someone but would be a huge help to me. I am using Dreamweaver, PHP, mySQL!

 

Thanks!

 

 

 

Link to comment
Share on other sites

Well, considering that you don't know how to do this, you're probably using cookies. If you're using cookies, i can help. It's really easy. To log in with a cookie, don't just put a few variables in a few cookies. This is a pretty easy trick to use.

 

//login code
//put this above the <html> tag(whenever or however you output it)
$user = array();
$userdata_sql = "'SELECT * FROM `users` WHERE `id` = $id"; //or however you prefer doing MySQL queries...
$userdata = mysql_query($userdata_sql);
while($userd = mysql_fetch_assoc($userdata))
{
$x = implode(',', $userd);
setcookie('user', $x, time()+999999);
}
//"session" management
//really isn't session variables!
if(isset($_COOKIE["user"]))
{
list($user["name"], $user["id"]) = explode('.', $_COOKIE["user"]); 
//the list must be in exact order as the fields in your mysql database.
}
//then just put $user["name"] wherever you want their name to be.  simple, no?

 

It's an easy way to emulate session management without really learning session techniques. It's not near as secure, though.

Link to comment
Share on other sites

  • 1 month later...
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.