Reputation: 3
I have a php page that contains a form with information I post to another php page.
When I click submit, it opens a new page in a target="_blank" and posts form data. However, after that happens, I want to reload the current page. Is this possible? I would also settle for redirecting the existing page to another, if reloading is not possible.
Is this achievable?
Upvotes: 0
Views: 4160
Reputation: 40492
Quick solution:
<form action="..." target="_blank"
onsubmit="setTimeout('location.reload()', 500);">
...
</form>
Or for redirecting:
<form action="..." target="_blank"
onsubmit="setTimeout('location.href=\'/new/url\'', 500);">
...
</form>
Upvotes: 5
Reputation: 219804
Just set a hidden form field with the URL of the page you want the user redirected to. Then after the form is processed use header()
to redirect the user to that page. You can also use a session for this.
Upvotes: 1