1 回答

TA貢獻1780條經驗 獲得超4個贊
我使用 PHP 會話來存儲然后刪除變量。
<?php
session_start();
$send_form = $_POST["email_form"]; //this is sent by ajax. Will be 'yes' if the form to send has been submitted.
switch ($action){
case 'stripe':
//do stripe transaction
//set a variable to indicate payment is complete using transaction ID
$_SESSION["payment_made"] = $transaction->id;
break;
case 'paypal':
//do paypal transaction
//set a variable to indicate payment is complete using transaction ID
$_SESSION["payment_made"] = $transaction->id;
break;
}
function sendmail() {
//usual php mail function (works fine)
session_unset();
session_destroy();
mail();
}
if ($send_form = 'yes' && $_SESSION["payment_made"] != '') {
sendmail();
}
?>
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報