Kryllster Posted May 19, 2013 Share Posted May 19, 2013 I had my own way of doing this until I started worjing with a friend.He gave me a pice of code to use and I have no idead how to get it to work (he is way more advanced than me) here is the code I cant figure out what to do with it. <?php function logged_in(){ if (isset ($_SESSION['username'])){ $_SESSION['username'] == true; } } if(logged_in()) { echo "<div id=\"navi\">";include "content/website/header.php";"</div>"; echo "<div id=\"content\">";include "layout/game.php";"</div>"; echo "<div style=\"clear:both;\"></div>"; echo "<div id=\"footer\">";include "content/website/footer.php";"</div>"; } else { echo "<div id=\"navi\">"; include "content/website/main_header.php"; "</div>"; echo "<div id=\"content\">"; include "layout/content.php"; "</div>"; echo "<div style=\"clear:both;\"></div>"; echo "<div id=\"footer\">"; include "content/website/main_footer.php"; "</div>"; } ?> Anywy I basicaly have the main website where the else clause is and the site for my game in the logged in pard . What to do?? Quote Link to comment https://forums.phpfreaks.com/topic/278150-how-do-i-use-this/ Share on other sites More sharing options...
ignace Posted May 19, 2013 Share Posted May 19, 2013 Your logged_in() function does nothing. So your else part will always execute. I also believe you don't want to compare your username to true unless you want to make sure it's not empty or something. function logged_in() { return !empty($_SESSION['username']); } Quote Link to comment https://forums.phpfreaks.com/topic/278150-how-do-i-use-this/#findComment-1430935 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.