cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: HTTP POST with PHP & cURL and follow redirect

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 22 Aug 2001 11:16:10 +0200 (MET DST)

On Tue, 21 Aug 2001, Roger Chang wrote:

> Here is what I want to simulate:
> 1) Person A goes to http://www.mysite.com
> 2) He fills out the form and hits submit (which runs
> http://www.mysite.com/script.php)

I figure that is your site and your script.

> 3) In script.php, I want to process the form information and then POST to
> http://www.post-to-me.com/action2.asp

I trust that is not a problem, right?

> 4) So after my script POSTS to http://www.post-to-me.com/action2.asp, Person
> A's browser should have the 2nd half of the form and the URL in the browser
> should show http://www.post-to-me.com/action2.asp

Hey hey hey. Hold your horses! ;-)

Your script posts to http://www.post-to-me.com/action2.asp and you get a full
page of HTML back (to your PHP program). Person A's browser is now on
http://www.mysite.com/script.php and doesn't show anything unless your script
decides to do so.

You want the browser to skip over to http://www.post-to-me.com/action2.asp?
You send a 'Location:' header to the browser to make it go there.

*BUT* it is not likely to work, as the site was designed to go there on a
POST operation and when using Location: you go there with a GET request.

Also, you talk about "the 2nd half of the form". What do you mean? When the
browser is pointing you your site, your scripts output whatever you think the
browser should see. When you send off the browser to that other site, you're
no longer in control and thus the other site controls what is sent to the
browser.

> How can I do this using the standalone cURL module? I did not compile
> PHP with the cURL option.

You can do all operations using either, it just gets more effective and
easier with the built-in version.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-08-22