|
Posted by Captain Paralytic on 07/13/07 12:09
On 13 Jul, 12:57, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> 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.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -
But my reading of what he said is the he wants to validate data in the
form before posting it and redirecting the user to the paypal site.
Indeed he specifically says that the user stays on his page, rather
than being sent to the paypal page.
So the validation is to be done BEFORE sending the form (and the user)
to the paypal site.
I would tend to do the validation by javascript if possible, or if I
had to do it serverside I'd use AJAX methods.
Navigation:
[Reply to this message]
|