mamba Posted January 3, 2012 Share Posted January 3, 2012 I want to limit guest what he can see (some kind of demo mod), but guest can always be able to login and see all related pages with his(her) username. What is best result to do that? I am trying to avoid header location, but if I do, what shall I put for $userid variable, as there is query requesting $userid. Any ideas? Quote Link to comment Share on other sites More sharing options...
sniko Posted January 4, 2012 Share Posted January 4, 2012 Insert a new row into `settings`, and call it game_demo and make the value of it 1 (TRUE) Now, put in globals (at the bottom, just above ?>); $demoAccount = 2; /* Demo account ID */ $demoPages = array('index.php', 'explore.php', 'gym.php'); /* Pages that the demo account can view */ if(!in_array(basename($_SERVER['PHP_SELF']), $demoPages) AND $userid == $demoAccount AND $set['game_demo'] == 1) { echo "You are on the demo account, meaning you cannot be here<br /> <a href='index.php'>Back</a>"; exit($h->endpage()); } Then, add to the array and change the value of $demoAccount to the demo accounts ID in the users table. I hope that helps. Quote Link to comment Share on other sites More sharing options...
mamba Posted January 6, 2012 Author Share Posted January 6, 2012 THANKS! I only added $demoAccount = 2; /* Demo account ID */ on the beginning of globals, as I am using it for checking. It works perfectly. Also modified globals to allow guest to see pages: replaced if($_SESSION['loggedin']==0) { header("Location: ".$boardurl."/login.php");exit; } with if($_SESSION['loggedin']==0) { $_SESSION['userid']=$demoAccount; } Quote Link to comment 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.