i'm trying to create an update form where whenever the process is done it will display the script tag before redirecting the browser to the header('Location: regUser.php'). everything is ok except it doesn't display the script tag. any help please? tq
Asked
Active
Viewed 33 times
0
-
1When you use a `Location:` header, the contents of the page are ignored, it just redirects immediately to the new URL. – Barmar May 06 '15 at 15:17
-
1Since you've shared no code, voting to close as insufficient detail. But you've probably got this problem: http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – Marc B May 06 '15 at 15:18
-
You can redirect from the client using javascript by setting the [location property](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) to the new address. Combine that with deferred execution using `setTimeout` should do the trick (in a strictly technical sense, 1.) this is not a redirect, and 2.) you are not setting the location property but use a convenience method. For practical purposes, both aspects shouldn't matter. Ymmv). – collapsar May 06 '15 at 15:21
1 Answers
0
You won't be able to use the header function to change location (sends browser a HTTP 300-level code indicating a redirect) AND output html.
It sounds like you want to use an HTML redirect, such as
<meta http-equiv="refresh" content="2;URL='http://my.other.site/'" />
where the number in Content is the number of seconds, and the URL is the target url.
This redirect is displayed on the page (and you can have your script tag and other content displayed) and relies on the browser to redirect after the specified amount of time.

fbas
- 1,676
- 3
- 16
- 26