eerikk2 Posted March 14, 2010 Share Posted March 14, 2010 I have an account login form so users can log into my website. What i want to do is show like "Welcome ______________. You are logged in. I head about putting the name in a session but i am unaware of how to go about doing this. Link to comment https://forums.phpfreaks.com/topic/195221-display-logged-in-username/ Share on other sites More sharing options...
frobak Posted March 14, 2010 Share Posted March 14, 2010 once your happy with the users login details, add the username to global variable: $_SESSION['username'] = $username; and then display it as you would any other variable: <?php echo $_SESSION['username']; ?> Any good to ya? Link to comment https://forums.phpfreaks.com/topic/195221-display-logged-in-username/#findComment-1026019 Share on other sites More sharing options...
prakash911 Posted March 14, 2010 Share Posted March 14, 2010 hey i am also trying to do something like this, but i want to display the username of the logged in user at the top of my navigation bar on every page and if the user decides to log out the navigation bar no longer would display the username. how about do i do this. i am fairly new to php so a clear explanation would be appreciated. Link to comment https://forums.phpfreaks.com/topic/195221-display-logged-in-username/#findComment-1026022 Share on other sites More sharing options...
eerikk2 Posted March 14, 2010 Author Share Posted March 14, 2010 thank you very much that helped greatly. as for displaying it make a new div tag and put <?=$_SESSION['username']?> as the content to display the username. if no user is logged in nothing will be displayed and one other quick question: I am having it able for users to upload data to a mysql database. how would i store their username in the users column. I have this as my sql statement $sql = "INSERT INTO Species( user ) VALUES ( '$_SESSION[username];' )"; however, nothin is being stored, the column is empty Link to comment https://forums.phpfreaks.com/topic/195221-display-logged-in-username/#findComment-1026038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.