PHP POST 到 URL,用户被重定向
所以我在我的网站上制作了一个结帐购物车。我使用 PayPal 作为支付系统,但在将客户转移到 PayPal 之前,我会获取他们的详细信息。为此,我从index.php 发布到index.php,运行我的代码来检索发布的信息并将其存储在数据库中,现在希望将客户重定向到PayPal。
不幸的是,您必须将所有购物车数据发布到 PayPal:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
我看到的唯一方法是发布到 index.php,收集用户数据,然后显示一个按钮,显示单击此处通过 PayPal 付款。这是我想避免的一个额外步骤。
有什么方法可以发布到index.php,收集数据,然后将PayPal信息发布到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.
Unfortunately you have to POST all the cart data to PayPal:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
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.
Any way to POST to index.php, collect the data, then post the PayPal info to the PayPal website? Or any other ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的页面上需要两个表单,一个表单回发到index.php,第二个表单
在第一个表单回发到index.php后发布到paypal,在body标记中回显javascript以在它提交时提交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
after the first form posts back to index.php, echo javascript in the body tag to submit the paypal form when it loads
您可以使用 JavaScript 以编程方式触发提交,例如:
You may fire submitting programmatically with JavaScript, eg:
您不需要需要按照其他答案中提到的方式重新从客户处发布您的表单。您可以改为使用 cURL 将数据POST 到 PayPal,并使其对用户来说都是透明的。有点像转发已发布的表格。您可以对数据进行操作(保存、操作或其他任何操作)并将帖子转发到 Paypal,所有这些都在单个用户事务中完成。
这是一个简单的示例: http://davidwalsh.name/execute-http-post-php-卷曲
You do not need to re-post your form from the client in the sense mentioned in other answers. You can instead use cURL to POST the data to PayPal and make it all look transparent to the user. Kinda like a forwarding of the posted form. You act on the data (save it, manipulate it or whatever) and forward the post to Paypal all in a single user transaction.
Here's a simple example: http://davidwalsh.name/execute-http-post-php-curl