Few days back when I was writing some PHP, I found out that
header( 'location: xyz.php' );
was not working on my hosting. The problem was headers were being sent by the server before processing the entire php. So I added this function at the top of the php file to buffer the output stream,
and the below function at the bottom of the php file to flush the buffer.
This solved my problem.