phpwiz Posted August 12, 2009 Share Posted August 12, 2009 Ok i made a site with a login and register script and it all works perfectly and stuff but i dont what to echo every single bit of my content. it will make sense after i post the code. <?php if ($_SESSION['username']) echo "Welcome, ".$_SESSION['username']."!"; echo "all the current content"; else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> i want it so i dont have to post it in an echo, so i can just post content instead of: echo "content"; can someone please help me with this problem!!! Link to comment https://forums.phpfreaks.com/topic/169886-session-help/ Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 Sorry, that makes no sense at all. Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896215 Share on other sites More sharing options...
phpwiz Posted August 12, 2009 Author Share Posted August 12, 2009 Sorry, that makes no sense at all. so i don't have to post the content inside of the php Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896217 Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 You need to explain what your trying to do. Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896220 Share on other sites More sharing options...
phpwiz Posted August 12, 2009 Author Share Posted August 12, 2009 You need to explain what your trying to do. i thought it over and would something like this work? <?php if ($_SESSION['username']) echo "Welcome, ".$_SESSION['username']."!"; ?> content here <?php else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> test Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896221 Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 That is valid syntax yes, still not sure what your question is though. Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896222 Share on other sites More sharing options...
phpwiz Posted August 12, 2009 Author Share Posted August 12, 2009 That is valid syntax yes, still not sure what your question is though. ok i tried doing that and it didnt work i got this error Parse error: syntax error, unexpected T_ELSE in /home/www/poke-gfx.awardspace.co.uk/index2.php on line 53 Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896223 Share on other sites More sharing options...
phpwiz Posted August 12, 2009 Author Share Posted August 12, 2009 ...can anyone help me with this please?? Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896225 Share on other sites More sharing options...
bundyxc Posted August 12, 2009 Share Posted August 12, 2009 Brackets, brackets, brackets. <?php if ($_SESSION['username']) { echo "Welcome, ".$_SESSION['username']."!"; ?> content here <?php } else { die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); } ?> test Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896227 Share on other sites More sharing options...
phpwiz Posted August 12, 2009 Author Share Posted August 12, 2009 Brackets, brackets, brackets. <?php if ($_SESSION['username']) { echo "Welcome, ".$_SESSION['username']."!"; ?> content here <?php } else { die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); } ?> test WOW i cant belive i missed that Link to comment https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.