By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

php header() help

P: n/a
bob
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?

Thanks for your help,

Ben.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"bob" <sp**@wrathofthebarclay.co.uk> wrote in message
news:3f***********************@mercury.nildram.net ...
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?

Thanks for your help,

Ben.


I suppose, if you wanted to turn them into GET vars.
You could do something like this...

<?
$url = "error.php?";
while(list($key, $value) = each($HTTP_POST_VARS))
$url .= $key . "=" . $value . "&";
header("Location: $url");
?>

Jul 17 '05 #2

P: n/a
Use the status code 307.

header("HTTP/1.0 307 Temporary Redirect");
header("Location: error.php");

Uzytkownik "bob" <sp**@wrathofthebarclay.co.uk> napisal w wiadomosci
news:3f***********************@mercury.nildram.net ...
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?

Thanks for your help,

Ben.

Jul 17 '05 #3

P: n/a
Regarding this well-known quote, often attributed to bob's famous "Fri, 5
Dec 2003 00:32:11 -0000" speech:
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?

Thanks for your help,

Ben.


You could GET, I imagine, by using something like--

Location: error.php?error=404

--but I imagine POSTing is out of the question...

Or, are you asking if POSTed variables, POSTed to a page that errors out,
can be preserved? That, I'm not sure... I'll have to check on that...
there'd be some interesting processing ideas there, I imagine.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #4

P: n/a
*** bob wrote/escribió (Fri, 5 Dec 2003 00:32:11 -0000):
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?


You can process POST data normally in the document where you've placed
header() function. However, you can't send feedback to browser. If you
need so you should pass GET data to the redirected page:

$name=trim($_POST['name']);
$result=insert_name_into_database($name);
header('Location: http://www.site.com/error.php?result='.urlencode($result));
exit;
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #5

P: n/a
bob wrote:
I use the following code to redirect the browser on an error,
header("location:error.php");
exit;

Is it possible to pass POST variables on as if a form was submitted, using
header()?


PEAR are your friend in this case :)

http://pear.php.net/package/HTTP_Request

Otherwise you can find a class to do HTTP Post requests at:
http://phpclasses.upperdesign.com/br...ml/package/375

Regards,
Johan

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.