Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    previously visited page

    How would you get the previous page's url in php code
    I want to have a link to the page the user just came from but it could have been a number of different pages.

    Thanks

  • #2
    New Coder
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    59
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Use the superglobal to know where they came from:

    PHP Code:
    $_SERVER[HTTP_REFERER
    Last edited by zactanaz; 03-24-2007 at 07:47 PM.

  • #3
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Unfortunately $HTTP_REFERER is not foolproof. Some browsers do not send this information, or can be made to send false information. You should keep this in mind when working with $HTTP_REFERER.

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Use a session and setup tracking. Navigation History baby! OR just update the database with there history for every page they click if you dont want to use sessions. Thats fool proof

    Use $_SERVER['REQUEST_URI']; for the "present" URL.


  •  

    Posting Permissions

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