Hi all,
I want to perform cash transactions such as cash deposits and cash withdrawals in my project.Here i have created a page called transaction.php to fulfill those requirements.But there were few error which i need your help to sought it out..
account (account_number, account_type, fd_period, account_balance, account_interest )
transacion (tran_id, to_account_number, from_account_number, transaction_type, transaction_amount, transaction_date )
<?php
$connect=mysql_connect("localhost","root","");
mysql_select_db("bank",$connect) or die ("could not select database");
if(isset($_POST['submit'])){
$query= "SELECT `full_name` FROM account_details WHERE `account_number`='".$_POST['account_number']."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($result)==1 and $row['account_balance']<$_POST['transaction_amount'] and strtolower($_POST['transaction_type'])=="withdrawal"){
echo "Insufficient balance";
}elseif(mysql_num_rows($result)==1){
if(strtolower($_POST['transaction_type'])=="deposit"){
$query = "INSERT INTO transaction (to_account_number) VALUES ('".$_POST['to_account_number']."')";
mysql_query($query) or die (mysql_error());
$operator = "+";
}else{
$operator = "-";
$query = "INSERT INTO transaction (from_account_number) VALUES ('".$_POST['from_account_number']."')";
mysql_query($query) or die (mysql_error());
}
$query= "UPDATE account SET `account_balance`=(`account_balance`".$operator.$_POST['transaction_amount'].") WHERE `account_number`='".$_POST[ 'account_number']."'";
mysql_query($query) or die(mysql_error());
$query = "INSERT INTO transaction (transaction_type, transaction_amount, transaction_date)
VALUES('".$_POST['transaction_type']."','".$_POST['transaction_amount']."','".$_POST['transaction_date']."')";
mysql_query($query) or die(mysql_error());
echo $row['full_name'].",<br> your transaction has been successfully processed";
}else{
echo "invalid account number";
}
}
?>
Undefined index: account_balance in C:\wamp\www\MySite\php files\transactions.php on line 14
if(mysql_num_rows($result)==1 and $row['account_balance']<$_POST['transaction_amount'] and strtolower($_POST['transaction_type'])=="withdrawal"){
Undefined index: to_account_number in C:\wamp\www\MySite\php files\transactions.php on line 19
$query = "INSERT INTO transaction (to_account_number) VALUES ('".$_POST['to_account_number']."')";