I need to find a way to restrict how users can get to a page. I have a page that I would only like users to get to from another page. I don't want the users to be able to go to the second page directly by entering the URL. Is there a way to restrict this in PHP or HTML?
create a session on the first page and look for this session in the second page. If the session doesn't exist as you expect it should than they didn't get to the second page through the first.
code on page 1.
session_start(); $_SESSION['washere'] = 1;
code on page 2.
session_start(); if(isset($_SESSION['washere']) && $_SESSION['washere'] == 1) { // was here } else { // was not here }
good luck ! axo
lol... your post wasn't there when i opend the reply page 😃
or just check $_SERVER['HTTP_REFERER'] (http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server) on the second page
Thanks for the help!
I couldn't get the session_start(); to work without errors. I tried a number of things. I must have been doing something wrong but I couldn't find the problem.
But the $_SERVER method worked great.