QUOTE(musya @ 31 May, 2008 - 03:25 PM)

Is there a way to see if a certain page referred you to it?
For example I have a login script and it goes to a page that validates them and such but i dont want direct access to that page allowed, meaning that, the page will check to see if it was accessed by index.php which contains a form that sends the user to it. Does anybody know? or follow me?
Thank you.
Musya
There a couple of ways of doing this. The first is that you could try to use the $_SERVER['HTTP_REFERER'] variable.
CODE
<?php
$lastpage = $_SERVER['HTTP_REFERER'];
if ($lastpage != "index.php") {
header("Location: needpermission.php");
}
// The rest of your page goes here
?>
Be sure to put that at the top of your apge. needpermission.php is the page that you to redirect to. HTTP_REFERER doesn't always work though, so it can be very unreliable. You may want to set a session variable on the index page. If so, on your index page put the following
CODE
<?
session_start();
$_SESSION['indexAccessed'] = true;
// The rest of your index pages code
?>
Then at the top of your processing processing page you would put
CODE
<?php
if ( ! ($_SESSION['indexAccessed']) ) {
header("Location: redirectpage.php");
}
$_SESSION['indexAccessed'] = false;
// Process the form
?>
Hope that helps. Let me know if you need any more assistance.