-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransfer.php
More file actions
102 lines (91 loc) · 3.85 KB
/
transfer.php
File metadata and controls
102 lines (91 loc) · 3.85 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once 'config.php';
?>
<html>
<head>
<title>BANKING PAGE</title>
<link rel="stylesheet" href="transfer.css" type="text/css">
</head>
<body>
<div class="transfer">
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
<label for="acc_no" >Account Number <em>*</em></label>
<input id="acc_no" name="acc_no" required="" readonly value="<?php echo $_GET['acc_no']; ?>" type="text" />
<label for="b_acc_no">Benificiary Account Number <em>*</em></label>
<input id="b_acc_no" name="b_acc_no" pattern="[0-9]+" maxlength="16" title="Enter 16 Digit number and Only numbers are allowed." required="" type="text" />
<label for="IFSC">IFSC <em>*</em></label>
<input id="IFSC" maxlength="15" required="" name="IFSC" type="text" />
<label for="amount">Amount <em>*</em></label>
<input id="amount" maxlength="10" required="" name="amount" type="text" />
<br>
<br>
<button id="transfer" type="submit" name="transfer">PAY NOW</button>
<br>
<br>
</form>
</div>
</body>
</html>
<?php
if(isset($_POST['transfer']))
{
$account = $_POST['acc_no'];
$b_account = $_POST['b_acc_no'];
$IFSC = $_POST['IFSC'];
$t_amount = $_POST['amount'];
$check_bal="select balance from customer where acc_no='{$account}'";
$res=mysqli_query($cn,$check_bal);
if(mysqli_affected_rows($cn) > 0)
{
while($r = mysqli_fetch_assoc($res))
{
$bal = $r['balance'];
if($bal > $t_amount)
{
$chech_b_acc = "SELECT * FROM customer where acc_no = '{$b_account}'";
$r2 = mysqli_query($cn,$chech_b_acc);
if(mysqli_affected_rows($cn) > 0)
{
$check_ifsc = "SELECT * FROM customer where IFSC = '{$IFSC}'";
$r3 = mysqli_query($cn,$check_ifsc);
if(mysqli_affected_rows($cn) > 0)
{
$add_amount = "UPDATE customer SET balance = balance + '{$t_amount}' where acc_no = '{$b_account}'";
if(mysqli_query($cn,$add_amount))
{
$sub_amount = "UPDATE customer SET balance = balance - '{$t_amount}' where acc_no = '{$account}'";
if(mysqli_query($cn,$sub_amount))
{
echo "<script> alert('Amount transferred successfully.'); window.location = 'index.php';</script>";
}
else
{
echo "<script> alert('Something went wrong!!! Please try again.'); window.location = 'transfer.php';</script>";
}
}
else
{
echo "<script> alert('Something went wrong! Please try again.'); window.location = 'transfer.php';</script>";
}
}
else
{
echo "<script> alert('Wrong IFSC code. Please try again.'); window.location = 'transfer.php';</script>";
}
}
else
{
echo "<script> alert('Account does not exist.'); window.location = 'customer.php';</script>";
}
}
else
{
echo "<script> alert('Insufficiant Balance.'); window.location = 'customer.php';</script>";
}
}
}
else
{
}
}
?>