Hi all,
According to my project, if a customer opens an account he should be able to deposit or withdraw cash. This is my table structure.
account_details (account_number, nic, full_name, name_with_initials, phone_number, address, gender, date_of_birth)
account (account_number, account_type, fd_period, account_balance, account_interest)
transaction (tran_id, transaction_type, from_account, to_account, transaction_amount, transaction_date)
I want following things to be done.
•When clicks on submit button, the name of the customer should be displayed with “transaction has completed successfully”.
•If a customer wants to withdraw an amount more than the available amount his account a message should be displayed as " Insufficient balance"
•If the user entered an incorrect account number, a message should be displayed as “Invalid account number”
Since iam new to PHP, i seriously want some help from u guys…
Specially the transactions.php page needs to be changed according to above information
The 4 pages are as follows.
NOTE : An Accounts opening officer is responsible for the opening of accounts and a teller’s duty to deposit or withdraw cash from/to accounts
open_account.php
[php]
Untitled DocumentAccounts Opening Form
<?php if(isset($_POST['run'])){include_once "./handlers/account.php";} ?> Customer details
<tr>
<td> </td>
<td> </td>
<td> </td>
<tr>
<td> </td>
<td align="center"> </td>
<td> </td>
account.php
[php]
<?php $connect=mysql_connect('localhost','root',''); mysql_select_db('bank',$connect); //Create Array $info = array( 'nic' => $_POST["nic"], 'full_name' => $_POST["full_name"], 'name_with_initials' => $_POST["name_with_initials"], 'phone_number' => $_POST["phone_number"], 'address' => $_POST["address"], 'gender' => $_POST["gender"], 'date_of_birth' => $_POST["date_of_birth"], 'account_type' => $_POST["account_type"], 'fd_period' => $_POST["fd_period"]
);
//Prepare the Insert Query
$insert_query = "INSERT INTO account_details (
nic,
full_name,
name_with_initials,
phone_number,
address,
gender,
date_of_birth
)
VALUES
(
‘$info[nic]’,
‘$info[full_name]’,
‘$info[name_with_initials]’,
‘$info[phone_number]’,
‘$info[address]’,
‘$info[gender]’,
‘$info[date_of_birth]’
)";
//Run a switch on the chosen type of account
if($info[‘account_type’] == “abhimani_plus”) {
if($info[‘gender’]!=“female”) {
//Show error messages here
echo “You do not meet the critera required to open this account.”;exit;
}
}
//Account Creation Here
$r = mysql_query($insert_query);
if($r) {
echo “A new account with number “.mysql_insert_id().” has been created successfully.”;die();
}
?>
[/php]
cash_transactions.php
[php]
Untitled Document
Cash Deposits / Withdrawals
Transaction details
Transaction Type | Deposits Withdrawels | |
[/php]
transactions.php
[php]
<?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"){ $operator = "+"; }else{ $operator = "-"; } $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 (account_number, transaction_type, transaction_amount, transaction_date) VALUES('".$_POST[ 'account_number']."','".$_POST['transaction_type']."','".$_POST['transaction_amount']."','".$_POST[ 'transaction_date']."')"; mysql_query($query) or die(mysql_error()); echo $row['full_name'].",your transaction has been successfully processed on "; }else{ echo "invalid account number"; } } ?>
[/php]