Re: POST method to php page from php page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux