-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.php
211 lines (181 loc) · 5.12 KB
/
transfer.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>ECO BANK</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
<style>
body{
background-color:#2b67f8;
}
</style>
</head>
<body>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="popper.min.js" type="text/javascript"></script>
<script src="sweetalert.min.js" type="text/javascript"></script>
</body>
</html>
<?php
session_start();
$server="localhost";
$username="root";
$password="";
$con=mysqli_connect($server,$username,$password,"qxp");
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>Online Bank System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
<style>
body{
background-color:white;
}
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 400px) {
.topnav.responsive {position: relative;}
}
<?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;
}
}
if($flag==true){
$sql = "SELECT * from customer where name='$sender'";
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
$s_acc=$row['Acc_Number'];
}
$sql = "SELECT * from customer where name='$receiver'";
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
$r_acc=$row['Acc_Number'];
}
$sql = "INSERT INTO `transfer`(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>";
}
?>
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
.user_details{
font-size:20px;
color:black;
font-weight:bold;
width: 20%;
height:auto;
margin: auto;
margin-left:auto;
margin-right:auto;
text-align: left;
}
}
</style>
</head>
<body>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="popper.min.js" type="text/javascript"></script>
<script src="sweetalert.min.js" type="text/javascript"></script>
<h1 align='center'>Transaction Successfull !!</h1>
<div class="user_details">
<div style="float: center">
<table class="center">
<?php
if (isset($_SESSION['user']))
{
$user=$_SESSION['user'];
$result=mysqli_query($con,"SELECT * FROM customer WHERE Name='$user'");
while($row=mysqli_fetch_array($result))
{
echo "<form method ='post' action = 'transfer.php'>";
echo "<tr><td><p><b>User ID     <td>:     </td></b> </td><td>".$row['UserID']."</td></tr></p>";
echo "<tr><td><p name='sender'><b>Name<td>:</td> </td><td>".$row['Name']."</td></tr></p>";
echo "<tr><td><p><b>Email ID</b><td>:</td> </td><td>".$row['Email']."</td></tr></p>";
echo "<tr><td><p><b>A/C No.</b><td>:</td> </td><td>".$row['Acc_Number']."</td></tr></p>";
echo "<tr><td><p><b>IFSC</b><td>:</td> </td><td>".$row['IFSC']."</td></tr></p>";
}
}
$result1=mysqli_query($con,"SELECT * FROM customer WHERE Name='$receiver'");
while($row=mysqli_fetch_array($result1))
{
echo "<tr><td><p><b>Receiver<td>:     </td></b></td><td>".$row['Name']."</td></tr></p>";
}
echo "</table>";
?>
<p align="center">
<input type="button" onclick="location.href='transc.php';" value="View Transactions" />
</p>
</body>
</html>