View Full Version : http refferer or better to refer user back?

10-18-2008, 08:15 AM
How would I be able to refer a user back to the page they came from?

This is purely for testing.

//Put your website address between the quotes below:
$websiteAddress = "www.example.com";
if (empty($_SERVER['HTTP_REFERER'])) {
$link = 'http://' . $websiteAddress;
} else {
if ($link != 'http://www.example.com'){
//send them back to where they came from.
// do nothing, or send them a message, oh and be nice.
echo "This is my cool page that does some cool stuff";


10-18-2008, 08:29 AM
you can use the history method in js

you could dev a function which collects pages visited in an array like a history function then use that to navigate backwards in time like breadcumbs

10-18-2008, 10:23 AM
I'm not that clued up on js, will have to google it.

10-18-2008, 12:29 PM
just the history() method

history.go(-1)">back in time</a>

change the int to go back n pages.

10-18-2008, 12:53 PM
Cool, thanks.

The basic js history parts I understand, but what you mean is that I need a database to capture the reffering pages. (This is my understanding, may be wrong)

In my instance - I just wanted to send them back to where they came from.

10-18-2008, 03:04 PM
cant you just use the 'HTTP_REFERER' and a session on every page ( $obj->referer() ) which just overwrites the session every time with the previous page

10-18-2008, 03:31 PM
I really don't know.
I only asked to see if there was a method, if not it's fine - my idea will do.