Any header information has the be the first output. This means that you can have server side code before it but if anything puts information to the browser it has to come after the header command.
Having read over your code I notice that you have whitespace. this is generally good practice but as far as headers are concerned it causes problems.
Check out the
manual.
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file
So try removing the white space, you can have many lines, just no white space between them. If that doesn't help you out post back and I'll take another look.
However, if that's a code snippet and it's actually within a div as your question suggests and you need to have the page output in there then header is not the solution for you. I'm not sure but cURL may work, it's not something I've ever used myself.
Cheers
nathj