Re: Re: Sending post data from a script

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

 



you can try this:

$sock = fsockopen($parse_url['host'], $parse_url['port'], $errno, $errstr, 30);
if (!$sock) {
       die("$errstr ($errno)\r\n");
}

$tmp = explode('&',$parse_url['query']);
$data = NULL;
foreach($tmp as $val) {
       $p = explode('=',$val);
       if(empty($data)) {
               $data  = $p[0] . "=" . urlencode($p[1]);
       } else {
               $data .= "&" . $p[0] . "=" . urlencode($p[1]);
       }
}

fwrite($sock, "POST " . $parse_url['path'] . " HTTP/1.0\r\n");
fwrite($sock, "Host: " . $parse_url['host'] . "\r\n");
fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
fwrite($sock, "Accept: */*\r\n");
fwrite($sock, "\r\n");
fwrite($sock, "$data\r\n");
fwrite($sock, "\r\n");

$body = "";
while (!feof($sock)) {
       $body .= fgets($sock, 4096);
}

fclose($sock);

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