logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



[php-source] PostToHost

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Sun 13 Aug '06 20:19    Post subject: [php-source] PostToHost Reply with quote

The following code can be usefull, cause it send the $data realy with POST

Code:

function PostToHost($host, $path, $referer, $data_to_send) {
$fp = fsockopen($host, 80);
printf("Open!\n");
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);
printf("Sent!\n");
while(!feof($fp)) {
$res .= fgets($fp, 128);
}
printf("Done!\n");
fclose($fp);

return $res;
}


$data = "pid=14&poll_vote_number=2";

printf("Go!\n");
$x = PostToHost(
"www.linux.com",
"/polls/index.phtml",
"http://www.linux.com/polls/index.phtml?pid=14",
$data
);
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1