Mr P!nk Posted September 24, 2007 Share Posted September 24, 2007 how can i stop people getting into a secure logged in page by just typing www.somesite.co.uk/admin/index.php. theres a login set up, but i can bypass it by just entering the url location, this is a major security issue that i need to solve relatively quickly before i publish the pages. what i need/want is if someone isn't logged in it just goes to a page saying "you must be logged in to access this page" then prompts them to login.php. thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 24, 2007 Share Posted September 24, 2007 Make a function which checks if they are logged in or not, and call it on every page. Quote Link to comment Share on other sites More sharing options...
Mr P!nk Posted September 24, 2007 Author Share Posted September 24, 2007 would that be with using sessions? thanks Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 24, 2007 Share Posted September 24, 2007 Yes, you will need to register a session after the user logs in This is a function that checks if a user is authed function is_authed_user() { // Check if the encrypted username is the same // as the unencrypted one, if it is, it hasn't been changed if (isset($_SESSION['username'])) { return true; } else { return false; } } On the page where you want to secure use something like this <?php if (!is_authed_user()) { print ('You need to login to view this page, <a href="/login">click here</a> to login.'); include('login.php'); } else { print('You ARE allowed to view this page } ?> Quote Link to comment Share on other sites More sharing options...
Mr P!nk Posted September 24, 2007 Author Share Posted September 24, 2007 thanks, ill go try this now, and let you know how it goes cheers for you help Quote Link to comment Share on other sites More sharing options...
Mr P!nk Posted September 24, 2007 Author Share Posted September 24, 2007 hmm its not working for me, it just lets me go to the page, but this time it has the login page at the top, its the same for both a user and a guest. thanks P!nk 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.