0

我有一个表单,提交时会收集数据并在我的数据库中写入字段的值。该表单使用对响应页面的发布请求,然后该响应页面连接到数据库并将所有必需的字段发布到我的数据库。

我还有一个称为付款的单选按钮,其中一个选项是贝宝。我的目标是最终将字段发布到数据库,但同时也将下面的表单数据一次性发布到我的贝宝帐户

<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="myemails" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="item_name" value="Digital Download" />
<input type="hidden" name="amount" value="9.99" />
<input type="hidden" name="return" value="http://myurl/form.htm" />
<input type="hidden" name="notify_url" value="http://myurl/example/ipn.php" />
<input type="image" src="btn_buynow_LG.gif" border="0" name="submit" alt="Paypal" />
</form>

我知道我可以使用下面的命令重定向到另一个具有表单的页面

if($_REQUEST['payment']=="Paypal") { redirect to another page with the code above, but the user has to click on submit again} 

但是,我只想让用户单击一次提交,然后我的数据库记录详细信息,然后自动将它们重定向到贝宝。

4

2 回答 2

1

这很简单,只需执行以下操作:

if($_POST['submit']) {
    // save the POSTed data to the DB
}

// now for PayPal
if($_POST['payment'] == "Paypal") {
    // now connect to PayPal API and process a payment
}

我建议在需要和/或在需要的地方$_REQUEST使用和使用。 $_GET$_POST

于 2012-12-14T16:14:23.323 回答
-1

不确定是否理解您的问题,但您应该在页面加载时将临时数据创建到您的数据库中,并且当 paypal api 回调调用您的 inp.php 时,将您的临时数据转换为经过验证的数据

于 2012-12-14T16:19:47.860 回答