So in other words you do have output before your headers. In fact, you try to shovel a load of stuff out to the user, and then try and send them to another page before they've seen it. A bit wasteful, that.
Try searching the forums for "cannot modify header information".