我怎样才能做到相当于使用 PHP 提交表单两次?
我的表格有问题。我需要它只需单击一次提交即可执行两项操作。我读到最好的解决方案是服务器端脚本,但我对 PHP 的了解非常有限,所以我非常感谢任何帮助。
我需要执行的两个操作是:
- 运行上传文件并发送电子邮件的脚本 (
action="uploader.php"
) - 将用户引导至 PayPal 支付网关 (
action= “https://www.paypal.com/cgi-bin/webscr”
)
据我所知,问题是我无法控制 PayPal 脚本,但它显然从形式(即数量、概念等),因此在 uploader.php
中添加简单的重定向是不够的。
你怎么认为?我该如何解决呢?
谢谢!
更新:我将尝试发布用户操作流程:
- 用户填写表单并添加文件以上传
- 第一个表单操作:上传文件并发送电子邮件(
action="uploader.php")
- 第二个表单操作:用户被带到 paypal 付款表单 (
action="https://www.paypal.com/cgi-bin/webscr"
) - 购买完成后,用户被带到购买确认页面。
I have a problem with a form. I need it to perform two actions with only one submit click. I've read that the best solution is a server-side script, but my knowledge of PHP is pretty limited, so I'd really appreciate any help.
The two actions I need to perform are:
- Run a script that uploads a file and sends an email (
action="uploader.php"
) - Direct the user to a PayPal payment gateway (
action="https://www.paypal.com/cgi-bin/webscr"
)
As I see it, the problem is that I don't have control over the PayPal script, but it obviously takes some data from the form (i.e. amount, concept, etc...), so adding a simple redirect in uploader.php
isn't enough.
What do you think? How could I solve it?
Thanks!
UPDATE: I'll try to post the user-action flow:
- user fills in the form and adds a file to upload
- 1st form action: file is uploaded and an email is sent (
action="uploader.php"
) - 2nd form action: user is taken to a paypal payment form (
action="https://www.paypal.com/cgi-bin/webscr"
) - When the purchase is completed the user is taken to a purchase confirmation page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的 uploader.php 应该向用户显示新的 paypal 表单(或相同的表单),并通过 dom 准备好的 javascript 提交它。
也不要忘记非 JavaScript 用户。
Your uploader.php should show the new paypal form (or the same) to user and submit it by javascript on dom ready.
Don't forget about non-javascript users too.
您可以将表单发送到submit.php,上传文件,执行电子邮件操作,然后使用CURL 将数据发送到PayPal。
该网站有一个如何通过 CURL/PHP 将数据发送到 PayPal 的示例:
http://curl.phptrack.com/forum/viewtopic.php?p=9643&sid=5cc0c394df6efcf73772273846430fbe
You can send the form to submit.php, upload your file, perform your email action, then use CURL to send your data on to PayPal.
This site has an example of how to send data to PayPal via CURL/PHP:
http://curl.phptrack.com/forum/viewtopic.php?p=9643&sid=5cc0c394df6efcf73772273846430fbe