RE: [PHP] Header Redirect & POST

From: Date: Fri, 26 Mar 2004 10:19:43 +0000
Subject: RE: [PHP] Header Redirect & POST
Groups: php.general 
Request: Send a blank email to php-general+get-181547@lists.php.net to get a copy of this message
On 25 March 2004 20:17, Chris Thomas wrote: > I am not sure if this was designed like this, or if its just > something im doing wrong. > > Im posting some data to a processing page, where i handle it then use > Header('Location: other.php') to direct me to another page. > > The problem that im running into is that the posted data is available > in other.php. > I would like to get it so that in other.php $_POST should be > an empty array At a guess, you're using Apache and it's doing an "internal redirect" because you've used a relative pathname (so the file must be in the same document root!); in this case, Apache just does a silent internal substitution of the redirect page, and all data associated with the context will remain intact -- there is no round-trip back to your browser. If you use an absolute URL in the Location: header, Apache will return the redirect to your browser -- and because your browser now knows it's a genuine new request, the POST data is not resent. The trick is to look at the URL appearing in your browser's address bar -- if it stays as the originally requested address, Apache did an internal redirect; if it changes to the redirect address, it was an external redirect which round-tripped to your browser. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#181547) next »