unknown gamer Posted May 25, 2008 Share Posted May 25, 2008 Ok, i have this code i got from the website i got my login system from: <?if($session->logged_in){ echo "You are viewing the protected page";}else{ echo "You are not allowed to view this page";}?> it works fine:Linkthen i try to put parts of my menu in there so when there logged in they can only see "Home" but if they are not logged in show them "Home, link, link" in the navigation bar. the code is: <?if($session->logged_in){ <div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li></ul></div>}else{ <div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li><li><a href="#">link</a></li><li><a href="#">link</a></li></ul></div>}?> The page doesn't even show up...here is my full menu code: <?if($session->logged_in){ <div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li></ul></div>}<div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li><li><a href="#">link</a></li><li><a href="#">link</a></li></ul></div> so how would i only show certain links when you're logged in or not? Link to comment Share on other sites More sharing options...
Ingolme Posted May 25, 2008 Share Posted May 25, 2008 You have to close the PHP code with <?php and ?> <?phpif($session->logged_in){?> <div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li></ul></div><?php } else { ?><div class="menu"><ul><li><div class="caption">Navigation</div><li><a href="index.php">Home</a></li><li><a href="#">link</a></li><li><a href="#">link</a></li></ul></div><?php } ?> Link to comment Share on other sites More sharing options...
unknown gamer Posted May 25, 2008 Author Share Posted May 25, 2008 It works!! Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.