Can anybody help me to sort out fsockopen issue in localhost.
I created fsock.php to post a variable to test121.php in the same folder. http://localhost/ftp/fsock.php
<?php
$fp = fsockopen('localhost/ftp');
$vars = array(
'hello' => 'world'
);
$content = http_build_query($vars);
fwrite($fp, "POST /test121.php HTTP/1.1\r\n");
fwrite($fp, "Host: localhost/ftp \r\n");
fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fwrite($fp, "Content-Length: ".strlen($content)."\r\n");
fwrite($fp, "Connection: close\r\n");
fwrite($fp, "\r\n");
fwrite($fp, $content);
header('Content-type: text/plain');
while (!feof($fp)) {
echo fgets($fp, 1024);
}?>
This was the code in test121.php http://localhost/ftp/test121.php
<?php
echo "<br><br>";
$raw_data = $GLOBALS['HTTP_RAW_POST_DATA'];
parse_str( $raw_data, $_POST );
//test 1
var_dump($raw_data);
echo "<br><br>";
//test 2
print_r( $_POST );
?>
I am getting Failed to parse address error in fsock.php. Can anybody explain me how to sortout this issue in localhost. Thank you in advance.