Page 1 of 1

Redirect to Another Page

Posted: Fri May 26, 2006 9:09 pm
by cscrofani
Hi, I'm looking for a way to redirect to another page. A fellow php user told me to use the 'header' command, as shown here:

Code: Select all

if (empty($zip))
{
	header ("Location: http://data.honoluluacademy.org/zipcode.php");
	exit;
}
but that always gives me some nonsense about header information already being sent.

I just want a simple redirect, instead of sending header information. How can I accomplish this?

There's gotta be a way... It seems a robust language like php wouldn't overlook such a simple function, right?

Thanks,
Chris

Posted: Fri May 26, 2006 9:20 pm
by Burrito
header() is what you want. The reason you're getting the header information already sent is because the server has sent something down to the client before the header() function is called.

you need to make sure you are not echoing anything out (including whitespace or sending cookies) before you call header().

Posted: Fri May 26, 2006 9:43 pm
by cscrofani
Alrighty, thanks!