A common problem PHP developers may encounter while redirect a page to another is :
Warning: Cannot modify header information – headers already sent by ….
when using the code below:
header( "Location: $url" );
There are different ways to solve this problem:
- Open your php.ini file. It is under the main directory of your PHP installation in Windows and
/etc in Unix/Linux
- Restart your Apache server
output_buffering = off
output_buffering = 4096
- At the start of your PHP script/page put
<php? ob_start(); ?>
This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. Just make sure that you call ob_end_flush() the appropriate number of times. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order.