SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    UK
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Obtaining previous page URL

    Hi all,

    Here's the scenario:

    I'm on 'index.php' of my site, I then goto 'contact.php' which has a sendmail script, which when completed / submitted, it fires up another page which has a meta refresh at the top to re-direct the user.

    It's easy enough to use something like $HTTP_REFERER on the third page which would take me back to 'contact.php', but I'd like to take the user back to the 2nd from last page (in this case 'index.php').

    How can I obtain the URL form the first page so that the re-direct takes them back two pages?

    Hope you get what I'm trying to do.

    Matt

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think there is a PHP function for that.

    But you might come up with something using sessions. On each page update a session that is holding the HTTP_REFERER. When going to next page, the session will then hold the HTTP_REFERER for two pages back.

    Think that should work. You only have to be carefully that you don't update the session before you use it on a page.

    HTH

    -Helge

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Gent, Belgium, Europe, World, Univers
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just get the referer on the contact page, store it in the form and submit it along with the data, then read from the form and redirect on the submitted page ...

  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_SERVER['HTTP_REFERER'] isn't always sent, it depends upon the browser..
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Gent, Belgium, Europe, World, Univers
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In that case, just pass it along with your link.

    contact.php?previous=index.php

    Save that in the form, retrive it again, and refresh ...


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
  •