Today I've faced the following problem: lets create two simple PHP files and put it to the server root:
send.php
<body>
<?
$data = <<<END
POST /rec.php HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Lenght: 7
a=1&b=2
END;
$fp = fsockopen ("127.0.0.1", 80, $errno, $errstr, 20);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, $data,strlen($data));
while (!feof($fp)) {
$output .= fgets ($fp,128);
}
fclose ($fp);
echo str_replace("\n","<br>",$output);
}
?>
</body>
rec.php
<?
echo "<br>Value of a:$a<br>Value of b:$b<br>";
?>
Responce should be like:
Value of a=1
Value of b=2
but, instead of 1 and 2, rec.php returns nothing. Don't blame me for using /n instead of /r/n in HTTP requests and missing Host and Accept headers - it works great with GET method. Do you have any ideas, what's happened?
Thanks,
IF