Redirect if not referred from specific page

Here’s the scoop:
I don’t want anyone adjusting the id url parameters and accessing pages they shouldn’t be seeing.

So basically…how do I make it so details.php is ONLY accessible by clicking a link from the master.php page? I don’t want anyone to be able to access it by typing in the url, and I don’t want it to be clickable through any other link other than master.php thats on my site. If it’s hotlinked or directly accessed, I want to redirect them to index.php

Is there a php solution? Or an .htaccess solution? I have no idea how to do this and it’s driving me nuts! Please help!

Thanks!

There are different ways to do this. One is to check $_SERVER[‘HTTP_REFERER’] (note that it is misspelled) field which should contain the URL of the referring page. I say ‘should’, because some browsers don’t provide it. So it won’t work for some users.

Another option could be to create a session variable on page one and check that it is set on page two. Then the user can enter page 2 anytime and by any means, provided they’ve been to page 1.

I’d use the last method if it were me.

Thanks, that sounds good. Too bad I have no clue how to do this! I’m using Dreamweaver in case that helps. Is there a tutorial or some sample code I can see? I do not know where to begin with this.
Thanks