+ Reply to Thread
Results 1 to 5 of 5

 

Thread: PHP - Previous page

  1. #1
    Member

    Status
    Offline
    Join Date
    Jan 2004
    Location
    UK
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts


    Morning all,

    Have no more hair to pull so thought I'd ask a basic question.

    I want to create a variable that holds the previously visited URL on my site e.g.

    I have $_SESSION['previous_page'] = $_SERVER['PHPSELF'];

    But when I call it from /catalogue.php?r=2&c=5

    The variable only holds /catalogue.php

    Anyone know a better way to go back to the previous url with it's parameter's?

    Cheers,

    Chris.
    Holiday Villa In<br>
    <font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>

  2. #2
    Typing with both fingers.

    Status
    Online
    Join Date
    Aug 2003
    Location
    Allt Y Coed Farm, North Pembrokeshire
    Posts
    4,122
    Thanks
    246
    Thanked 197 Times in 156 Posts
    Hi

    You could either use

    $_SESSION['previous_page'] = $_SERVER['PHPSELF']."?".$HTTP_SERVER_VARS['QUERY_STRING'];

    which would have to be in the previous page


    or you could try using the reffer document

    $_SESSION['previous_page'] = $_SERVER['HTTP_REFERER'];

    but you would have to use this code in the document that you were executing.

  3. #3
    Senior Member

    Status
    Offline
    Join Date
    Sep 2003
    Posts
    768
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Try using REQUEST_URI rather than PHP_SELF .

    This will also preserve the get vars

  4. #4
    Member

    Status
    Offline
    Join Date
    Jan 2004
    Location
    UK
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks all, new it would be simple.

    Chris.
    Holiday Villa In<br>
    <font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>

  5. #5
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think the variable you need is $_SERVER['HTTP_REFERER'] but this is empty if anyone is using Norton privacy

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2