SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    knowing from what page I came from

    Hello people

    I have 3 pages in the application
    both page A.html and page B.html have a link to page C.php
    When I get to page C.php I need to know from what page I came from.

    I know that I can pass it as a parameter in the URL, but I was wondering if there is a more basic construct in PHP that will allow me to know this without having to perform an explicit action

    regards

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    use $_SERVER['HTTP_REFERER']...
    (it's in the manual!)
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Addict trogdor1024's Avatar
    Join Date
    Oct 2004
    Location
    New Jersey
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, there is a referrer variable that you could use, but I don't trust using it if you need accuracy.

    Do you by any chance make the user log in before they would see these pages? If so you can track each pageload in the database and just lookup the last page that the user was on fairly painlessly.

  4. #4
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

    I will see if that will work

  5. #5
    SitePoint Zealot kamm's Avatar
    Join Date
    Nov 2003
    Location
    Espaņa
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    'HTTP_REFERER'

    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.


    'REQUEST_URI'
    The URI which was given in order to access this page; for instance, '/index.html'.


    Maybe basename and REQUEST_URI like this;

    Code:
    basename($_SERVER['REQUEST_URI'])


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •