我怎样才能做到相当于使用 PHP 提交表单两次?

发布于 2024-09-14 12:34:13 字数 661 浏览 9 评论 0原文

我的表格有问题。我需要它只需单击一次提交即可执行两项操作。我读到最好的解决方案是服务器端脚本,但我对 PHP 的了解非常有限,所以我非常感谢任何帮助。

我需要执行的两个操作是:

  1. 运行上传文件并发送电子邮件的脚本 (action="uploader.php")
  2. 将用户引导至 PayPal 支付网关 (action= “https://www.paypal.com/cgi-bin/webscr”

据我所知,问题是我无法控制 PayPal 脚本,但它显然从形式(即数量、概念等),因此在 uploader.php 中添加简单的重定向是不够的。

你怎么认为?我该如何解决呢?

谢谢!

更新:我将尝试发布用户操作流程:

  1. 用户填写表单并添加文件以上传
  2. 第一个表单操作:上传文件并发送电子邮件(action="uploader.php")
  3. 第二个表单操作:用户被带到 paypal 付款表单 (action="https://www.paypal.com/cgi-bin/webscr")
  4. 购买完成后,用户被带到购买确认页面。

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:

  1. Run a script that uploads a file and sends an email (action="uploader.php")
  2. 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:

  1. user fills in the form and adds a file to upload
  2. 1st form action: file is uploaded and an email is sent (action="uploader.php")
  3. 2nd form action: user is taken to a paypal payment form (action="https://www.paypal.com/cgi-bin/webscr")
  4. When the purchase is completed the user is taken to a purchase confirmation page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉 2024-09-21 12:34:13

你的 uploader.php 应该向用户显示新的 paypal 表单(或相同的表单),并通过 dom 准备好的 javascript 提交它。
也不要忘记非 JavaScript 用户。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="myForm">
  <!-- obviously hidden input's -->
  <script type="text/javascript">
    window.onload = function(){
      document.getElementById("myForm").submit();
    }
  </script>
  <noscript><input type="submit" value="Continue to Paypal!" /></noscript>
</form>

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.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="myForm">
  <!-- obviously hidden input's -->
  <script type="text/javascript">
    window.onload = function(){
      document.getElementById("myForm").submit();
    }
  </script>
  <noscript><input type="submit" value="Continue to Paypal!" /></noscript>
</form>
所谓喜欢 2024-09-21 12:34:13

您可以将表单发送到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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文