Re: Re: Putting $_POST into string to send to ASP

From: Date: Fri, 16 Jul 2004 20:42:38 +0000
Subject: Re: Re: Putting $_POST into string to send to ASP
References: 1 2 3  Groups: php.general php.general 
Request: Send a blank email to php-general+get-190757@lists.php.net to get a copy of this message
Jeff Oien wrote:
Thanks for the helpful examples. One other question. Is there an advantage to sending the URL via a header as opposed to doing http_post like this? http://shiflett.org/hacks/php/http_post Jeff
As mentioned a couple of times, size is one. But you still need to url-encode the data if you're going to send it via post. <?php $data = array('item1' => 'value1', 'item2' => 'value2'); $query_string = http_build_query($data); // Now, you can send the data either via post: $response = http_post('www.example.com', '/form.php', $data); // ...or via get: header('http://www.example.com?form.php?' . $data); ?> The first lets your script grab the output of the form to which you're submitting (it's in $response after the http_post() call); the second actually loads and displays the target form. Another option is cURL, which is designed for exactly this sort of thing: http://www.php.net/curl ...but it may or may not be overkill for what you need. However, cURL pretty much rules the data posting/fetching game as far as configurability etc. Cheers, Torben <torben@php.net>

« previous php.general (#190757) next »