Posted by Philip Hallstrom on 04/08/05 19:08
> Hello all
>
> Does anyone know if its possible to post data using the http POST method to
> another form using php?
Yes. If you search around you'll find some pure-PHP code snippets to do
this... or do it yourself...
To programmatically make a POST request you need to open a socket
connection to the web server on port 80 and
send the following information:
--------------------------------------------------------------------------
POST /path/to/form.php HTTP/1.1
Host: www.somehost.com
Content-type: application/x-www-form-urlencoded
Content-length: 71
Connection: close
xxxxxxxx=urlencoded_xxxxxxx_data&yyyyyyyyyyy=urlencoded_yyyyyyyyyy_data
--------------------------------------------------------------------------
Each line is terminated by a single newline (\n).
Content-length is simply the length of the data being sent (the last line
in this case).
You'll need to urlencode the data in order to transport it safely. See
this for more info on what this does: http://us3.php.net/urlencode. Only
encode the actual data though... that is the stuff after the equal sign.
Then you'll need to read back the response headers and do whatever you
want from there...
[Back to original message]
|