提交时发生两件事
我的表单操作将隐藏的输入发送到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能是这样的
May be like this
更好地使用类如
better to use a class like
为什么不直接用 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.