将PHP POST重定向到URL,并重定向用户 [英] PHP POST to URL with user being redirected

查看:102
本文介绍了将PHP POST重定向到URL,并重定向用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在网站上结帐.我使用PayPal作为支付系统,但是在将客户转移到PayPal之前,我先了解了他们的详细信息.为此,我将从index.php POST到index.php,运行我的代码以检索POSTed信息并将其存储在数据库中,现在希望将客户重定向到PayPal.

So I'm making a check out cart on my website. I'm using PayPal as the payment system but before I transfer the customers to PayPal I get their details. To do that I POST from index.php to index.php, run my code to retrieve the POSTed info and store it in a database and now wish to redirect the customer to PayPal.

不幸的是,您必须将所有购物车数据发布到PayPal:

Unfortunately you have to POST all the cart data to PayPal:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

我看到的唯一方法是将内容发布到index.php,收集用户数据,然后显示一个按钮,说单击此处通过PayPal付款.这是我要避免的另一步骤.

The only way I see around this is to post to index.php, collect the user data, then have a button show up saying click here to pay via PayPal. That's one extra step that I want to avoid.

有什么方法可以发布到index.php,收集数据,然后将PayPal信息发布到PayPal网站?还是其他想法?

Any way to POST to index.php, collect the data, then post the PayPal info to the PayPal website? Or any other ideas?

谢谢

推荐答案

您将需要在页面上使用2种形式,一种形式发回index.php,另一种形式发给paypal

you would need 2 forms on your page, one form that posts back to index.php and a second form that posts to paypal

第一个表单发回index.php后,在body标签中回显javascript以在加载时提交贝宝表单

after the first form posts back to index.php, echo javascript in the body tag to submit the paypal form when it loads

    <?php
   if(isset($_POST['mydatafield'])){

        do database stuff

        $LOAD = 'document.paypal.submit();';
    }
    ?>
    <body onload="<?php echo $LOAD ?>">
    <form name="paypal" action="paypal.com?yadayada">
    paypal fields
    </form>
    <form name="myform" action="index.php">
    your form stuff
    submit button
    </form>

这篇关于将PHP POST重定向到URL,并重定向用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆