gpt4 book ai didi

php - 在表单提交时发送电子邮件

转载 作者:太空宇宙 更新时间:2023-11-03 15:47:17 24 4
gpt4 key购买 nike

我需要在客户按下“使用 paypal 付款”按钮(下例中的名称=提交)后向特定地址发送电子邮件。问题是表单立即将我重定向到另一个页面( Paypal 网站),所以我发送电子邮件的代码无法通过:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="xxx@company.com">
<input type="hidden" name="item_name" value="Lunch Run ONLINE ORDER">
<input type="hidden" name="amount" value="<PASS-THRU-CODE-HERE>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type=hidden name="return" value="http://www.xxxxx.com/order-confirmation.html">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="img/paypal.png" border="0" name="submit" alt="Make payments with any major credit card!">
</form>

我愿意接受任何想法,谢谢大家。

最佳答案

试试这个。您需要进行两次 ajax 调用。

<form id="clickonpaypalbutton">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="xxx@company.com">
<input type="hidden" name="item_name" value="Lunch Run ONLINE ORDER">
<input type="hidden" name="amount" value="<PASS-THRU-CODE-HERE>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type=hidden name="return" value="http://www.xxxxx.com/order-confirmation.html">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="img/paypal.png" border="0" name="submit" alt="Make payments with any major credit card!">
</form>



<script>
$('#clickonpaypalbutton').submit(function(event) {
if(confirm('Confirm?' )) {
event.preventDefault();
$.ajax({
type: 'POST',
url: 'https://www.paypal.com/cgi-bin/webscr',
data: $(this).serialize(),
success: function (data) {
console.log(data);
}
});

$.ajax({
type: 'POST',
url: 'path-to-your-email-sending-script',
data: $(this).serialize(),
success: function (data) {
console.log(data);
}
});
} else {
event.preventDefault();
return false;
}
});
</script>

关于php - 在表单提交时发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36546939/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com