Jump to content

Archived

This topic is now archived and is closed to further replies.

justintabb

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

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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!

 

 

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Are you using a DW Login form?

 

If so it will create it's own session variable.

 

<?php echo $_SESSION["MM_Username"]; ?>

Share this post


Link to post
Share on other sites

×

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.