-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.php
More file actions
225 lines (184 loc) · 6.47 KB
/
Copy pathtransfer.php
File metadata and controls
225 lines (184 loc) · 6.47 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
session_start();
$server="localhost";
$username="root";
$password="";
$con=mysqli_connect($server,$username,$password,"banksystem");
if(!$con)
{
die("Connection failed");
}
$flag=false;
if (isset($_POST['transfer']))
{
$sender=$_SESSION['sender'];
$receiver=$_POST["reciever"];
$amount=$_POST["amount"];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Banking System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicon for title logo-->
<link rel="shortcut icon" href="https://img.icons8.com/nolan/96/bank-building.png" type="image/x-icon" />
<!-- Stylesheet link path -->
<link rel="stylesheet" href="style.css" />
<!-- social media icon of fontawesome -->
<script src="https://kit.fontawesome.com/680832fd8d.js" crossorigin="anonymous"></script>
<!-- CDN Link of sweetalert -->
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<style>
body{
background-color: rgb(17 17 17);
}
.header_trans {
background: url(./img/mony_heist_transfer_security.jpg);
height: 88.6vh;
background-size: cover;
background-position: center;
position: relative;
/* color: yellow; */
}
@media only screen and (max-width: 444px){
.header_trans {
background: url(./img/mony_heist_transfer_security.jpg);
height: 60vh;
background-size: 100% 80%;
background-repeat: no-repeat;
background-position: center;
position: relative;
color: yellow;
}
}
</style>
</head>
<body>
<!--
#######################################
navbar
#######################################
-->
<div class="fix__nav" id="home">
<div class="navigation">
<div class="nav_container">
<div class="nav__logo">
<a href="/">TSF BANK</a>
</div>
<div class="nav__menu">
<ul class="nav__list">
<li class="nav__item">
<a href="index.html#home" class="nav__link ">Home</a>
</li>
<li class="nav__item">
<a href="view.php" class="nav__link ">Customer</a>
</li>
<li class="nav__item">
<a href="Transc.php" class="nav__link ">Transactions</a>
</li>
<li class="nav__item">
<a href="README.md" class="nav__link ">About</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--
#######################################
Header
#######################################
-->
<div class="header_trans">
<!-- img background set via internal CSS -->
</div>
<!--
=====================================================
Footer
=====================================================
-->
<div class="fix__nav_footer">
<footer id="footer" class="section__footer">
<div class="copyright">
<p></p>
</div>
<div class="follow">
<div class="follow__icon">
<a href="#" target="_newtab"><i class="fab fa-instagram-square"></i></a>
<a href="#" target="_newtab"><i class="fab fa-github-square"></i></a>
<a href="#"><i class="fab fa-youtube-square" target="_newtab"></i></a>
<a href="#" target="_newtab"><i class="fab fa-facebook-square"></i></a>
</div>
</div>
</footer>
</div>
</body>
</html>
<?php
$sql = "SELECT Balance FROM customer WHERE name='$sender'";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if($amount > $row["Balance"] or $row["Balance"]-$amount < 100){
echo "<script> swal( 'Transaction Denied','Insufficient Balance!','error' ).then(function() { window.location = 'view.php'; });;</script>";
}
else{
$sql = "UPDATE `customer` SET Balance=(Balance-$amount) WHERE Name='$sender'";
if ($con->query($sql) === TRUE) {
$flag=true;
}
else {
echo "Error in updating record: " . $conn->error;
}
}
}
}
else {
echo "0 results";
}
if($flag==true){
$sql = "UPDATE `customer` SET Balance=(Balance+$amount) WHERE name='$receiver'";
if ($con->query($sql) === TRUE) {
$flag=true;
}
else {
echo "Error in updating record: " . $con->error;
}
}
//Transcation Detailed Stored in the DB
if($flag==true){
//sender ac number fatching
$sql = "SELECT * from customer where name='$sender'";
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
$s_acc=$row['Acc_Number'];
}
//Receiver ac number fatching
$sql = "SELECT * from customer where name='$receiver'";
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
$r_acc=$row['Acc_Number'];
}
//Inserting data of sender name,ac number AND receiver name,ac number AND Amount to be transfer
$sql = "INSERT INTO `transactions`(s_name,s_acc_no,r_name,r_acc_no,amount) VALUES ('$sender','$s_acc','$receiver','$r_acc','$amount')";
if ($con->query($sql) === TRUE) {
}
else
{
echo "Error updating record: " . $con->error;
}
}
if($flag==true){
echo "<script>swal('Money sent', 'Your transaction was successful','success').then(function() { window.location = 'view.php'; });;</script>";
}
elseif($flag==false)
{
echo "<script>
$('#text2').show()
</script>";
}
?>