0

I'm creating a web page and I want to know if there is a way to block access to certain pages but reachable if PHP loads them. The idea is this; I have some modules that I include(); them with PHP. There will be no problem if users reach them by typing them into the address bar because they are managed with $_SESSION vars and they be seeing what they see in the included page but I just want to prevent that because if somebody discovers that link it is an uncomfortable view.

Ivan
  • 34,531
  • 8
  • 55
  • 100
Güney Saramalı
  • 791
  • 1
  • 10
  • 19

1 Answers1

0

This is the answer if anybody searches.

if(!isset($_SERVER['HTTP_REFERER'])){
    // redirect them to your desired location
    header('location:../index.php');
    exit;
}

at this to the top of the page inside php tags.

Güney Saramalı
  • 791
  • 1
  • 10
  • 19