thescientist Posted December 5, 2009 Share Posted December 5, 2009 yo, synook already gave the answer and I even commented on it! How has this still been going on? Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2009 Share Posted December 5, 2009 As people mentioned earlier, you cannot output any content before session_start(). Not even an empty space or a line break.session_start() has to be practically the first thing on the page, before any HTML, before any text and before any echo statements. Make sure there you don't leave any spaces or line breaks before the opening <?php block. Link to comment Share on other sites More sharing options...
kirbyweb Posted December 6, 2009 Author Share Posted December 6, 2009 I have this<?phpsession_start();Ok I fixed this, but it still does not display the name. Link to comment Share on other sites More sharing options...
kirbyweb Posted December 6, 2009 Author Share Posted December 6, 2009 Is it because I am basicly saying if the button was pressed once? then when I go to another page it goes away? Link to comment Share on other sites More sharing options...
Ingolme Posted December 6, 2009 Share Posted December 6, 2009 Is it because I am basicly saying if the button was pressed once? then when I go to another page it goes away?OK, the reason that it only displays the name when the form is submit is because you have that echo statement within the if() condition that checks for the form value.Remove this line:echo 'Welcome ' .$row["username"] .'.'; And add this after all the rest of the PHP, outside of any other if() blocks if(isset($_SESSION['username'])) { // If the username has been stored in a session variable echo 'Welcome ' . $_SESSION['username'] . '.'; } Link to comment Share on other sites More sharing options...
kirbyweb Posted December 6, 2009 Author Share Posted December 6, 2009 Thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.