request_uri alternative

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
My server host for whatever reason is not dishing out the correct
request_uri.  It is displaying the page viewing and not the page it was
linked from.

So...what I am looking for is an alternative to determine the previous
page from the site. (nothing from external).

This is what I have so far at the top of each page.

// Set previous page
if(isset($_SESSION['current_page'])) {
    $previous_page = $_SESSION['current_page'];
$_SESSION['current_page'] = $_SERVER['PHP_SELF'];

This works so far with limited testing.

Has anyone used a different method that they know that works?
Can you see any reason why my method may fail?


Re: request_uri alternative

On Tue, 16 Dec 2008 20:06:45 -0800, wrote:
Quoted text here. Click to load it


<code snipped>
Quoted text here. Click to load it

The REQUEST_URI server var is behaving correctly.  I suspect you want
HTTP_REFERER.  Just know that the referrer can be easily spoofed.

You should either loop through $_SERVER or check phpinfo() when you
need to find out what's available in your environment.

$email = str_replace('sig.invalid', '', $from);

Re: request_uri alternative

Quoted text here. Click to load it

There's several ways to solve the problem. Your solution will get
confused if the user opens more than one window and also has the
overhead of maintaining a session for every user. An alternative
approach would be to rewrite the URLs in all the links using
javascript to add a parameter identifying the current page, and add a
hidden field to any POST form with the same. But this does not address
the core issue - why do you need this information?


Re: request_uri alternative

I just found this interesting method:


Which amends the current page to a link and then they can be recovered
in the get variables on the next page.

The only problem I can find is that the URL is a bit messier in the
address bar.

Has anyone used this before or have found problems using it?


Site Timeline