1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| if($toption != "LT") {
//debit from sender,
//update transaction table,
//send email and show details to user.
$s_sql = "SELECT acc_no, user_id, balance FROM tbl_accounts WHERE acc_no = ?";
$s_result = dbQuery($s_sql,$sacc_no);
$s_acc = dbFetchAssoc($s_result);
//check if senders balance is not enough
$s_bal = $s_acc['balance'];
$s_uid = $s_acc['user_id'];
$s_accno = $s_acc['acc_no'];
$d_total = ($s_bal - $amt);
if($s_bal < $amt) {
header('Location: index.php?v=Transfer&msg=' . urlencode('You do not have enough balance to proceed with this transfer.'));
exit();
}
//update sender's account balance
$sql_sacc = "UPDATE tbl_accounts SET balance = ? WHERE user_id = ? AND acc_no = ?";
dbQuery($sql_sacc,$d_total,$s_uid,$s_accno);
$desc = sprintf("Fund transfer of $%u to Account %u Reference# %s", $amt, $acc_no, $tx_no);
$sql = "INSERT INTO tbl_transaction (tx_no, tx_type, amount, date, description, to_accno, status, tdate, comments)
VALUES (?, 'debit', ?, NOW(), ?, ?, 'SUCCESS', ?, ?)";
dbQuery($sql,$tx_no,$amt,$desc,$sacc_no,$date_of,$comments);
//email details...
// funds_transfer_mail($amt, $sacc_no);
$_SESSION['funds_data']['tx_no'] = $tx_no;
header('Location: index.php?v=IntFund');
exit();
} |