|
Posted by Jerry Stuckle on 07/13/07 11:57
Captain Paralytic wrote:
> On 13 Jul, 03:44, kelvin <kelvin...@yahoo.com.cn> wrote:
>> Hi,
>>
>> A difficult question.
>>
>> I have a form that I used to submit tohttps://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 tohttps://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
>
> This code will cause the sver to communicate with paypal, it won't
> affect the browser.
>
> You could send the form to the clinet and send an onload() script to
> automatically submit it.
>
The problem with that is he won't know if the transaction succeeded or not.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|