First off, I hope I'm not yet confused again and missing something.
I have the following to scripts
post.php
<?php
print_r($_POST);
?>
test.php
<pre>
<?php
echo http_post('wopr-mobile', '/post.php', 'payload');
function http_post($host, $path, $payload, $referer = '') {
// open HTTP connection
$fp = fsockopen($host,80);
if ($fp) {
// send request's header information
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
if (!empty($referer)) {
fputs($fp, "Referer: $referer\n");
}
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($payload)."\n");
fputs($fp, "Connection: close\n\n");
// send request's payload
fputs($fp, "$payload\n");
// recieve request's response
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
// close HTTP connection
fclose($fp);
// return result
return $result;
} else {
// return failure flag
return false;
}
}
?>
When I call test.php, I get the following output
HTTP/1.1 200 OK
Date: Sat, 20 Oct 2001 16:30:02 GMT
Server: Apache/2.0.26-dev (Win32)
X-Powered-By: PHP/4.2.0-dev
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
11
Array
(
)
0
Why is the $_POST array empty? When I change the print_r call in
post.php to output $GLOBALS I don't see the string 'payload', too.
--
Sebastian Bergmann
http://sebastian-bergmann.de/ http://phpOpenTracker.de/
Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]