Hi All,
Is it possible for php to be 'aware' of the url that's in a browser's address bar?

I have a small php script that I link to from a number of different html pages, say index1.html, index2.html, index3.html, ect..

Is there a function or somthing one can use that would let the script know if it were called by a link from index1.html rather than index2.html?

Thanks
Jeremy

    You can try $_SERVER['http_referer'], but be aware that this data is actualy sent by the client, so it can be a little unreliable.

      Aside from HTTP_REFERER you could set a SESSION variable in index1.html but rename it to index1.php and then check for that variable in the rest of the files.

      IE:

      session_start();
      
      if (isset($_SESSION['prevPage'])) {
            if ($_SESSION['prevPage'] == "index1") {
                   //execute code here
            }
      }
      
      // after all executing is done set the variable
      $_SESSION['prevPage'] = "index2";

        Thanks for the reply!

        I tried that out, but $_SERVER['http_referer'] doesnt seem to hold anything. Do I need to set this somwhere first?

        Thanks
        Jeremy

          Thanks,
          I think my soultion will look simmilar to that.
          Regards

            I tried that out, but $_SERVER['http_referer'] doesnt seem to hold anything.

            Because as I said, It is sent by the client. You probably have it disabled somewhere in your browser.

            Then again... It may need to be in all caps. A typo on my part.

            $_SERVER['HTTP_REFERER']

              Write a Reply...