Here's my predicament. I Have managed to send and retrieve some HTTP requests using the GET method successfully using the following code:
function send_to_host($host,$method,$path='/',$data='',$useragent=0){
// Supply a default method of GET if the one passed was empty
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80) or die("Unable to open socket");
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form- urlencoded\r\n");
if ($method == 'POST') fputs($fp, "Content-length: " . strlen($data) . "\r\n");
if ($useragent) fputs($fp, "User-Agent: MSIE\r\n");
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
send_to_host('humbot.freewebhostingpro.com','GET','/index.php?a=5','');
//sent from localhost
I have tried a few times to send some data via POST but haven't had any luck. (I haven't had any trace of the POST data getting through)
(set up a form to submit some GET and POST data to humbot.freewebhostingpro.com/index.php
and the page will display that data)
Any ideas?