Be careful where you use the header function, or you will get the following error.
Basically, it seems that no output operation should be performed before the HEADER function.
Warning: Cannot modify header information - headers already sent by (output started at