Hi.
I’m working on a banking system project and I need help with a few files that’s not working right. It’s a 3 part function that I’m having trouble with. Thanks in advanced.
netbanking.sql:
[php]
– Table structure for table accounts
CREATE TABLE IF NOT EXISTS accounts (
accno varchar(25) NOT NULL,
customerid int(10) NOT NULL,
accstatus varchar(25) NOT NULL,
primaryacc varchar(10) NOT NULL,
accopendate date NOT NULL,
accounttype varchar(25) NOT NULL,
accountbalance double(10,2) NOT NULL,
unclearbalance double(10,2) NOT NULL,
accuredinterest double(10,2) NOT NULL,
PRIMARY KEY (accno)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
– Dumping data for table accounts
INSERT INTO accounts (accno, customerid, accstatus, primaryacc, accopendate, accounttype, accountbalance, unclearbalance, accuredinterest) VALUES
(‘4661’, 98683, ‘active’, ‘40000’, ‘2013-02-11’, ‘sv’, 200000.00, 100.00, 100.00),
(‘4662’, 98683, ‘active’, ‘40000’, ‘2013-02-11’, ‘sv’, 100000.00, 100.00, 100.00);
–
– Table structure for table transaction
CREATE TABLE IF NOT EXISTS transaction (
transactionid int(10) NOT NULL AUTO_INCREMENT,
transactiondate date NOT NULL,
paymentdate datetime NOT NULL,
payeeid int(25) NOT NULL,
receiveid int(10) NOT NULL,
debitac varchar(25) NOT NULL,
amount float(10,2) NOT NULL,
paymentstat varchar(25) NOT NULL,
PRIMARY KEY (transactionid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2147483647 ;
– Dumping data for table transaction
INSERT INTO transaction (transactionid, transactiondate, paymentdate, payeeid, receiveid, debitac, amount, paymentstat) VALUES
(2147483647, ‘2012-12-13’, ‘2012-12-03 04:21:10’, 111232154, 0, ‘150000’, 100000.00, ‘active’);
[/php]
dbconnection.php - NO CHANGES NEEDED:
[php]
[/php]
accounttransfer.php
Ok. So, for this file, whenever someone chooses Transfer From, it is supposed to show the current balance in the Current Balance field so the customer will know if they have enough to transfer.
[php]
Make Account Transfer
| Transfer To: | Select<?php while($transferto = mysql_fetch_array($to, MYSQL_BOTH)) { echo "$transferto[0]"; } ?> |
| Transfer Amount: | |
| Transfer From: | Select <?php while($transferfrom = mysql_fetch_array($from, MYSQL_BOTH)) { echo "$transferfrom[0]"; } ?> |
| Current Balance: | <?php echo $currbal; ?> |
|
$to = $_POST[‘transferto’];
$from = $_POST[‘transferfrom’];
$amount = $_POST[‘amount’];
/if(isset($_POST[‘transfer1’]))
{
else
{
$result1 = mysql_query(“SELECT * FROM accounts WHERE accountsid=’$to’”);
$result2 = mysql_query(“SELECT * FROM accounts WHERE accountsid=’$from’”);
}
}
$transferarray = mysql_query(“SELECT * FROM accounts”);/
if(isset($_POST[“transfer2”]))
{
//$newbal = $_POST[‘currbal’] + $_POST[‘amount’];
if($_POST[trpass] == $_POST[conftrpass])
{
if($to === $from)
{
$error = "The account numbers are the same.<br>
Please <button onclick=\"history.go(-1);\">Go Back</button>
and choose a different account number.";
}
elseif($amount == "")
{
$error = "No amount has been entered.<br>
Please <button onclick=\"history.go(-1);\">Go Back</button>
and enter an amount.";
}
else
{
$error = "Failed to transfer";
}
if($to == TRUE)
{
$from = mysql_query("SELECT accountbalance FROM accounts WHERE accno='.$from.'
AND customerid='$_GET[customerid]'");
while($from = mysql_fetch_array($from, MYSQL_BOTH))
{
if($amount > $from[0])
{
$error = "Amount insufficient!";
$forward = false;
}
else
{
$sql = ("UPDATE accounts SET accountbalance = accountbalance - $amount WHERE accno = '.$from.'");
$sql = ("UPDATE accounts SET accountbalance = accountbalance + $amount WHERE accno = '.$to.'");
$currbal = mysql_query("SELECT accountbalance FROM accounts WHERE accno = '.$to.'");
if (mysql_query($sql))
{
// succeeded
$result1="INSERT INTO transaction(recipient,
payeeid,
depositac,
transactionmethod,
transactiontype,
accountbalance,
transactiondate)VALUES('$_POST[accno] $to',
'$_POST[accno] $from',
'$_POST[amount]',
'Cash',
'Transfer',
'$_POST[currbal]',
'$_POST[date]')";
header("Location: accounttransfer3.php");
}
}
}
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
}
}
mysql_close($dbc);
/*mysql_query ("UPDATE `` SET `` = `accountbalance` + `.$amount.`
WHERE `` = `..`");
//AND customerid='$_GET[customerid]'");*/
/*while($res = mysql_fetch_array($to, MYSQL_BOTH))
{
$updateamount = $res[0]+$amount;
mysql_query("UPDATE accounts SET accountbalance='$updateamount'
WHERE accno='$to'
AND customerid='$_GET[customerid]'");
}*/
/*else
{
$passerr = "<b>Invalic password entered...<br> Please re-enter transaction password</b>";
$payto = $_POST[paytoo];
$payamt = $_POST[amt];
$payacno= $_POST[payeeid];
}*/
}
//$acc= mysql_query(“select * from accounts where customer_id=’$_SESSION[customer_id]’”);
?>
Account Transfer 2:
$to = $_POST[‘accountnumber’];
$tranaction = mysql_query(“SELECT * FROM transaction”);
$trans = mysql_query(“SELECT * FROM transaction WHERE transactionid”);
while($rows = mysql_fetch_array($trans))
{
$recipient = $rows[‘accountnumber’];
$oldbal = $rows[‘oldaccountbalance’];
$newbal = $rows[‘accountbalance’];
}
mysql_close($con);
?>
Transaction Detail:
<?php
echo "Account Transfer Complete Successful...";
?>
| Recipient: | <?php echo $recipient; ?> |
| Old Balance: | <?php echo $oldbal; ?> |
| New Balance: | <?php echo $newbal; ?> |
