If you're going to use the header() function it HAS to be done before ANY output is sent, including whitespace, <html> tags, whatever. Since you haven't posted your whole script I can't tell you exactly what you've done wrong, other than sending stuff to the browser before trying to send headers.
Also, it doesn't make any sense to assign a string to a variable and then go off to another page where that variable will not be 'visible'. Your $problem assignment is useless.