469,266 Members | 2,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,266 developers. It's quick & easy.

php header() help

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
5 34054

"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
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
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
*** 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
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.

Similar topics

2 posts views Thread by Thomas Kemmerich | last post: by
18 posts views Thread by Frank Thorstens | last post: by
11 posts views Thread by DaRemedy | last post: by
2 posts views Thread by Karthik | last post: by
4 posts views Thread by Matthew Harvey | last post: by
3 posts views Thread by Grim Reaper | last post: by
2 posts views Thread by saleek | last post: by
10 posts views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.