Originally posted by: mugs
Header("Location: otherPage.php");
I use that because I like to keep validation/processing pages separate from entry/navigation pages.
Actually, PHP buffers it's output and headers, so by simply calling header('Location: myloc.php'); your script could execute unexpected code.
so, do this:
header("Location: otherpage.php");
exit;
Also, according to HTTP/1.1 standards, when you send a Location header, you're supposed to send a full, absolute URL (including the HTTP), so in reality you'd want to do something like:
header("Location:
http://myserver.com/myscript.php");
exit;
I actually use a function that determines what kinds of url you're trying to redirect to (local absolute, local relative, or remote) and formats an absolute URI, then redirects to it. I've attached to code snippet so you can see/use it. It can also handle querystrings on the end of the addresses, and encodes them correctly.
Usage:
// Local Relative
Redirect('../myurl.php');
or
Redirect('myurl.php');
// Local Absolute
Redirect('/myurl.php');
// Remote
Redirect("
http://www.myurl.com/")