justintabb Posted November 29, 2005 Share Posted November 29, 2005 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 Link to comment https://forums.phpfreaks.com/topic/2953-how-to-display-logged-in-as-user-name-on-index-page/ Share on other sites More sharing options...
ChrisDarl Posted November 30, 2005 Share Posted November 30, 2005 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! Quote Link to comment https://forums.phpfreaks.com/topic/2953-how-to-display-logged-in-as-user-name-on-index-page/#findComment-9955 Share on other sites More sharing options...
Taro Posted December 4, 2005 Share Posted December 4, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2953-how-to-display-logged-in-as-user-name-on-index-page/#findComment-10007 Share on other sites More sharing options...
degsy Posted January 5, 2006 Share Posted January 5, 2006 Are you using a DW Login form? If so it will create it's own session variable. <?php echo $_SESSION["MM_Username"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/2953-how-to-display-logged-in-as-user-name-on-index-page/#findComment-10621 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.