|
Posted by kelvin on 07/13/07 02:44
Hi,
A difficult question.
I have a form that I used to submit to https://www. paypal.com/cgi-bin/
webscr
<form action="https://www. paypal.com/cgi-bin/webscr" method="post">
Now I need to validate some inputs of this form, so I submit it to a
PHP page in my own server first.
<form action="paypal_upgrade_checking.php" method="post">
After validate, I need to submit the form again to https://www.
paypal.com/cgi-bin/webscr
I write a piece of PHP code but it failed. The browse is still in
paypal_upgrade_checking.php, it doesn't go to the new page.
I wonder whether there is a way to do it.
<?
....
$buf = '';
$req = '';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header="";
$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.sandbox.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
print "HTTP ERROR<br/>$errno<br/>$errstr";
exit();
} else {
fputs ($fp, $header . $req);
while(!feof($fp)) {
$buf.=fgets($fp,1024);
}
fclose($fp);
echo $buf;
}
?>
Thank you
Kelvin
[Back to original message]
|