View Full Version : Header Location Question


terreri
08-09-2006, 04:21 PM
Hi,

I'm new to PHP and was wondering how to code to go back to the previous page after executing a script. I was told to use the following command:

header("Location: " . $_SERVER['HTTP_REFERER']);
exit;

Is this the best way to do this? Is there another way?

Thanks!

phoztech
09-11-2006, 03:10 PM
be careful in that there can be no other output previous to that command meant for the screen.

The Webmaster
09-27-2006, 09:41 AM
[QUOTE=terreri]Hi,

I'm new to PHP and was wondering how to code to go back to the previous page after executing a script. I was told to use the following command:

header("Location: " . $_SERVER['HTTP_REFERER']);
exit;

Is this the best way to do this? Is there another way?

Thanks![/QUOTE]

If you want to Automatically redirect the user to the previous page then its the shortest method.

If not then you can use JavaScript's history.back() too