Jump to content


Photo

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


  • Please log in to reply
3 replies to this topic

#1 justintabb

justintabb
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 November 2005 - 07:41 AM

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!

#2 ChrisDarl

ChrisDarl
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 30 November 2005 - 03:00 PM

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) View Post[/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!
[/quote]




#3 Taro

Taro
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 December 2005 - 06:40 AM

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.

#4 degsy

degsy
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 05 January 2006 - 02:52 PM

Are you using a DW Login form?

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

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users