Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How do I get my webpage not to go back when they hit the back button and are logged out ?

how can I add a web page to be blocked like FACEBOOK doesn't let you get into their site with out having a page or a account with them, and if you try to put something in the url and try to go to something on their site it gives you a web page that says "you have to be logged in first" ?

I mean I don't want someone going to the url of the "index" page before they have signed up as a member they need to make an account first then they can have access to the "index" page. How do I do this gateway?

Consider I have a website so far that has a database and the website has 5 pages so far and two of them which is the login and sign up page which are both used with php and mysql and they work fine.

How do I restrict access to the main website by first having the users sign up with me for an account?

share|improve this question
    
You will have to add script code to each and every page to check whether someone is logged in or not. –  Marjan Venema Dec 16 '12 at 12:28
    
what do you mean? with like php or javascript ? –  noob1992 Dec 16 '12 at 12:40
    
Adding this to the top of a web page with the login php script sessioning these variables will help out on this topic a lot <?php session_start(); if(!$_SESSION['username'] && !$_SESSION['pass']){ header("location:error.php");}?> –  noob1992 Dec 16 '12 at 13:19
    
There are plenty tutorials out on the web to do so. Dop you have any specific problems in implementing the session handling? –  feeela Dec 19 '12 at 9:56

2 Answers 2

You need to use a PHP Session to check if the user has logged in or not, put the check code in each PHP page.

share|improve this answer

You need to add session in every page of the website in the start of the page and also a condition in login and sign up page that if a person is logged in with session than that would be redirect to inner pages and vice versa.

You also have another option to use MVC like structure having only single point of entry with session file together.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.