Thread: PHP redirecting
View Single Post
Old 04-17-2007, 01:34 PM   #4 (permalink)
CrazeD
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: PHP redirecting

If you use
Code:
<?php

header('Location: blahblah.com');

?>
in mid-HTML, you'll get a "Headers already sent" error.

To fix that, you'll have to use output buffering.

Example:
Code:
<?php
ob_start();
header('Location: blahblah.com');
ob_end_flush();
?>
This will buffer the PHP and execute any PHP scripts between the ob_start() and ob_end_flush() functions before it does anything else.

It's best to put ob_start(); as the very first piece of code on your page, and put ob_end_flush(); at the very end, therefore buffering (executing) the PHP before anything else.
__________________

Need website help? PM me!
CrazeD is offline