I have a .php file and I would like for it to only load if the user is coming from a specific page.
i.e. user must be coming from www.domain.com/main/index.php in order for page www.domain.com/web/music/test.php to load.
I have tried this:
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if ($referrer != 'www.domain.com/main/index.php') {
die("This page can only be accessed from www.domain.com/main/index.php.");
}
// put your page code here
?>
But it gives me this error: Notice: Undefined index: HTTP_REFERER
.
Any idea how to do this?