Clinton Posted April 22, 2008 Share Posted April 22, 2008 I am using this system located here to give me a base: http://www.devarticles.com/c/a/PHP/Creating-a-Membership-System/2/ This is the first page that someone comes to once they are logged in. It works just fine when logged in. When you are logged out it still displays this page just without the name. How do I prevent this? Do I use the session ID and include everything in an ELSE statement? If !.$SESSION['id'] then show nothing ELSE show the code below? <? session_start(); echo "Welcome ". $_SESSION['first_name'] ." ". $_SESSION['last_name'] ."! You have made it to the members area!<br /><br />"; echo "Your user level is ". $_SESSION['user_level']." which enables you access to the following areas: <br />"; if($_SESSION['user_level'] == 0){ echo "- Forums<br />- Chat Room<br />"; } if($_SESSION['user_level'] == 1){ echo "- Forums<br />- Chat Room<br />- Moderator Area<br />"; } echo "<br /><a href=logout.php>Logout</a>"; ?> <html> <head> <title></title> </head> <body bgcolor="#FFFFFF"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/102390-sessions-question/ Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 Never mind. When they log in I set a session variable to yes and it ran the ELSE statement. If works fine I just want to see if any of you professionals see any problem with it. Thanks! <? session_start(); if ( @$_SESSION['login'] == "yes") { echo "Welcome ". $_SESSION['first'] ." ". $_SESSION['last'] ." Login: ". $_SESSION['login'] ."! You have made it to the members area!<br /><br />"; echo "Your user level is ". $_SESSION['user_level']." which enables you access to the following areas: <br />"; if($_SESSION['user_level'] == 0){ echo "- Forums<br />- Chat Room<br />"; } if($_SESSION['user_level'] == 1){ echo "- Forums<br />- Chat Room<br />- Moderator Area<br />"; } echo "<br /><a href=logout.php>Logout</a>"; } else { echo "You have tried to enter a Employee Area only. Please login. <meta http-equiv='refresh' content='3;url=http://www.clintonandersen.name/NASG' /> "; } ?> <html> <head> <title></title> </head> <body bgcolor="#FFFFFF"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/102390-sessions-question/#findComment-524316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.