headers must be sent before you output any text at all -- even a single space char -- to the user's browser. check your script and make sure your script doesn't output any text before that header() call.
Another thing you might want to do is call exit immediately after you redirect -- otherwise the rest of your script may still echo text, etc.
Another option if you can't get that working is to echo "thank you" in this script and then user a meta refresh or javascript to forward the browser to the next page.