note 29102 deleted from function.fsockopen by nlopess

From: Date: Sat, 27 Dec 2003 15:19:06 +0000
Subject: note 29102 deleted from function.fsockopen by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62568@lists.php.net to get a copy of this message
Note Submitter: info@agriya.com ---- 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); }

« previous php.notes (#62568) next »