提交时发生两件事

发布于 2024-10-21 15:21:00 字数 2026 浏览 2 评论 0原文

我的表单操作将隐藏的输入发送到 PayPal 进行结帐。我还需要它在发送到 PayPal 之前向我发送电子邮件。

但由于我的表单的操作调用 paypal,我无法触发其他功能。我想我可以只使用 action=self 并在我的页面上执行我需要的操作,然后将 nessesery 帖子变量发送到 paypal。我在下面尝试一下:

<?
if(isset($_POST['submit'])){
//get post data for me clean up and save then send

if(!mail(data, myemail, headers)){
//send data to paypal. 
curl(https://www.paypal.com/cgi-bin/webscr);
}

}else{
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- DATA FOR ME-->

<p>Child's Name: <? echo $child_name; ?></p>
    <input type="hidden" name="child_name" value="<? echo $child_name; ?>">

<p>Birth Date: <? echo $birth_date; ?></p>
    <input type="hidden" name="birth_date" value="<? echo $birth_date; ?>">

<p>Parent/Guardian Name: <? echo $name; ?></p>
    <input type="hidden" name="name" value="<? echo $name; ?>">

<p>Email Address: <? echo $email; ?></p>
    <input type="hidden" name="email" value="<? echo $email; ?>">

<p>Home Phone: <? echo $phone; ?></p>
    <input type="hidden" name="phone" value="<? echo $phone; ?>">



<!-- DATA FOR PAYPAL-->
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>

一旦我的页面上的 mail() 函数成功,我是否应该使用curl 将数据重新发送到PayPal?不确定这将如何运作?

My form action sends hidden inputs to PayPal for checkout. I also need it to send me an email before it goes to paypal.

But since the action of my form calls paypal I cant trigger the other function. I was thinking I could just have the action=self and do what I need on my page and then send the nessesery post variables to paypal. I am taking a shot at it below:

<?
if(isset($_POST['submit'])){
//get post data for me clean up and save then send

if(!mail(data, myemail, headers)){
//send data to paypal. 
curl(https://www.paypal.com/cgi-bin/webscr);
}

}else{
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- DATA FOR ME-->

<p>Child's Name: <? echo $child_name; ?></p>
    <input type="hidden" name="child_name" value="<? echo $child_name; ?>">

<p>Birth Date: <? echo $birth_date; ?></p>
    <input type="hidden" name="birth_date" value="<? echo $birth_date; ?>">

<p>Parent/Guardian Name: <? echo $name; ?></p>
    <input type="hidden" name="name" value="<? echo $name; ?>">

<p>Email Address: <? echo $email; ?></p>
    <input type="hidden" name="email" value="<? echo $email; ?>">

<p>Home Phone: <? echo $phone; ?></p>
    <input type="hidden" name="phone" value="<? echo $phone; ?>">



<!-- DATA FOR PAYPAL-->
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>

Should I use curl to resend the data to PayPal once the mail() function on my page was successful? Not sure how that will work?

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

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

发布评论

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

评论(3

妞丶爷亲个 2024-10-28 15:21:00

可能是这样的

<?
$url = "";

if(isset($_POST['submit'])){
//get post data for me clean up and save then send

    if(!mail(data, myemail, headers)){
        $url = "https://www.paypal.com/cgi-bin/webscr";
    }

}else{
?>
<form action="<? echo $url; ?>" method="post">

<!-- Same form as in the original post -->

</form>

<?
if ($url != "") {
?>
<script language="javascript">
document.forms[0].submit();
</script>
<?
}
?>

May be like this

<?
$url = "";

if(isset($_POST['submit'])){
//get post data for me clean up and save then send

    if(!mail(data, myemail, headers)){
        $url = "https://www.paypal.com/cgi-bin/webscr";
    }

}else{
?>
<form action="<? echo $url; ?>" method="post">

<!-- Same form as in the original post -->

</form>

<?
if ($url != "") {
?>
<script language="javascript">
document.forms[0].submit();
</script>
<?
}
?>
梦途 2024-10-28 15:21:00


<input type='hidden' name='notify_url' value='http://yoursite.com/post.php?action=ipn' />
<input type='hidden' name='cancel_return' value='http://yoursite.com/post.php?action=cancel' />
<input type='hidden' name='return' value='http://yoursite.com/post.php?action=return' />

更好地使用类如

<input type='hidden' name='notify_url' value='http://yoursite.com/post.php?action=ipn' />
<input type='hidden' name='cancel_return' value='http://yoursite.com/post.php?action=cancel' />
<input type='hidden' name='return' value='http://yoursite.com/post.php?action=return' />

better to use a class like

守望孤独 2024-10-28 15:21:00

为什么不直接用 JavaScript 呢? onsubmit 例程可以 POST 到向您发送电子邮件的 CGI 脚本,然后返回一个真值,以便正常提交继续到 PayPal。


Come to think of it, you'd need to use AJAX methodology so your browser stays on the same page.

Why not just with javascript? An onsubmit routine can POST to a CGI script that sends you an email, then return a true value so that the normal submit follows through to PayPal.


Come to think of it, you'd need to use AJAX methodology so your browser stays on the same page.

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