--- "Chris W. Parker" <[EMAIL PROTECTED]> wrote:
> Ok I don't think this can be used in conjuction with a redirect but I'd
> like to find out. Here is some code I wrote up quick (and didn't test).
> What I'd like to happen (as well as a million other people???) is I POST
> the data back to the previous page and then redirect to that page having
> access to all the data I just POSTed.
> 
> <?php
> 
>       $postdata = "the data goes here";
>       $website = "http://some.website.com";;
>       $path = "/page.php";
>       $redirect = $website.$path;
> 
>       http_post($website, $path, $postdata);
> 
>       header("Location: $redirect"); exit;
> ?>

OK, this will "work", but not in the way you describe. You see, a POST
request is just that, a request. When you send this header:

header("Location: $redirect");

You are telling the browser to send a GET request to the URL $redirect.
What the user sees in the browser is the response to this GET request, not
the response to the POST request that you sent behind the scenes. If you
want the user to see the output of the POST request, you have to display
it to the user in your script rather than redirecting.

So, assign the return of http_post() to a variable, trim off the HTTP
headers, and echo that to the user. The URL in the user's browser will be
your script's, but hopefully that isn't a problem.

Hope that helps.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
     Coming mid-2004
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to