I have a problem I simply can't figure out.
I have a basket for use with paypal, however instead of letting the HTML for post directly (as would be the norm) I am trying to forward it instead, to allow some processing to be done.
I've researched to the point where fsockopen() seems the way to go, but PayPal doesn't like it, plus it puts the HTTP headers on the page!
Here's my script:
Code: Select all
$out = '';
foreach($_POST as $key=>$val){
$out.= $key."=".urlencode(stripslashes($val))."&";
}
$post = "POST cgi-bin/webscr HTTP/1.1\r\n";
$post.= "Host: www.paypal.com\r\n";
$post.= "Content-type: application/x-www-form-urlencoded\r\n";
$post.= "Content-length: ";
$post.= strlen($out)."\r\nConnection: close\r\n\r\n$out";
$fp = fsockopen("www.paypal.com", 80 , $errno, $errstr);
if (!$fp)die("Uh, oh.");
fwrite($fp,$post);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);Best regards,
H