Originally Posted by sunfighter
If the redirect works the browser stops executing script and goes to the other page so what comes after it does not execute.
Given this Put the alert box on the shipping page. If you need to use an if statement on it, send the if trigger as a GET in the url.
This is correct, but has a slight ambiguity in interpretation. Calling a header location asks your browser to move its location to another. The code following the header call will still execute per normal, but by using a Location header the browser itself will not render the returned HTML code, instead if follows the location to the new page.
So code wise, calling header(Location) will not stop the script from continuing. The script will continue until it finished and then send the headers and results to the client, where the client then detects the location and follows it instead of rendering. For this reason, header location is usually followed by an exit or die call, since more often than not the remaining process isn't required (but not always).
So yep, the HTML and JS in use needs to be provided by the page that the client will end up on. Using the querystring, a cookie or sessions are the best way, but will determine if the JS is constructed by the PHP (where you can use sessions), or simply by a hard coded JS (in which you should use the QS or possibly cookies [which I'd suggest you avoid overall]).