I'm submitting a form to itself with an anchor added to the URL so that when there are errors, the form is guaranteed to be in the viewport, here's a simplified example...
<form id="my_form" action="/form_link/#my_form" method="POST">
...
</form>
When /form_link/
receives the form post, it processes it, when there are errors it just continues loading the page again and shows the errors.
However when the post is successful it redirects to a different page using...
header('Location: /another_link/');
die;
The problem is that when I end up at the redirected link, the URL is actually...
/another_link/#my_form
instead of the expected...
/another_link/
I'm at a loss, the anchor is being added after the fact, so I have nothing to strip it from. How can I prevent this behaviour?
EDIT: Could the reason possibly be because nothing has yet been output to the browser between the form submit and the redirection? Is there anyway to clear whatever is in the header that's maintaining the anchor target?
EDIT 2: The headers that have already been sent as reported by headers_sent()
are:
[0] => X-Powered-By: ZendServer 6.3.0
[1] => Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
[2] => Expires: Thu, 19 Nov 1981 08:52:00 GMT
[3] => Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
[4] => Pragma: no-cache
[5] => Access-Control-Allow-Origin: **REMOVED**
[6] => Access-Control-Allow-Methods: GET, POST, OPTIONS
[7] => Access-Control-Allow-Headers: X-Requested-With
So I don't see anything in there that would affect follow up uses?!?!