提交表格&验证后转到新页面 [英] Submit a form & go to the new page after validate
问题描述
一个棘手的问题。
我有一个表格,我曾经提交给 https:// www 。 paypal.com/cgi-bin/
webscr
< form action =" https:// www。 paypal.com/cgi-bin/webscr" method =" post">
现在我需要验证这个表单的一些输入,所以我把它提交到我自己的一个
PHP页面服务器优先。
< form action =" paypal_upgrade_checking.php" method =" post">
验证后,我需要再次将表单提交给 https:// www 。
paypal.com/cgi-bin/webscr
我写了一段PHP代码,但失败了。浏览仍然在
paypal_upgrade_checking.php,它没有进入新页面。
我想知道是否有办法做到这一点。
< ;?
....
$ buf ='''';
$ req ='''';
foreach($ _POST as $ key = $ value){
$ value = urlencode(stripslashes($ value));
$ req。="& $ key = $ value";
}
$ header ="" ;;
$ header。=" POST / cgi-bin / webscr HTTP / 1.0 \\\\ nn ;;
$ header。=" Content-键入:application / x-www-form-urlencoded\r\\\
" ;;
$ header。=" Content-Length:" 。 strlen($ req)。 " \\\\\\ nn ;;
$ 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;
}
?>
谢谢
Kelvin
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
推荐答案
buf ='''';
buf = '''';
req ='''';
foreach(
req = '''';
foreach (
_POST as
这篇关于提交表格&验证后转到新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!