note 29102 added to function.fsockopen

From: Date: Sun, 02 Feb 2003 19:38:12 +0000
Subject: note 29102 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-43293@lists.php.net to get a copy of this message
I have seen in lot of places ppl asking on how to post data to another server using a php script...so here is what is required to do that... //create a string with all the posted data... foreach ($HTTP_POST_VARS as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } //create headers... $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); if (!$fp) { // ERROR echo "$errstr ($errno)"; } else { //put the data.. fputs ($fp, $header . $req); while (!feof($fp)) { //read the data returned... $res = fgets ($fp, 1024); } fclose ($fp); } -- http://www.php.net/manual/en/function.fsockopen.php http://master.php.net/manage/user-notes.php?action=edit+29102 http://master.php.net/manage/user-notes.php?action=delete+29102 http://master.php.net/manage/user-notes.php?action=reject+29102

« previous php.notes (#43293) next »