-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.php
More file actions
134 lines (119 loc) · 3.09 KB
/
transfer.php
File metadata and controls
134 lines (119 loc) · 3.09 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
<?php
session_start();
$server="localhost";
$username="root";
$password="";
$con=mysqli_connect($server,$username,$password,"ritika");
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 Serivice</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
<style>
body{
background-color:#2b67f8;
}
@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;}
.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;
}
}
</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
$sql = "SELECT Balance FROM users 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){
$location='Details.php?user='.$sender;
header("Location: $location&message=transactionDenied");
}
else{
$sql = "UPDATE `users` 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 `users` 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 users where name='$sender'";
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
$s_acc=$row['Acc_Number'];
}
// Transcation DEatiled Stored in the DB
$sql = "SELECT * from users 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){
$location='Details.php?user='.$sender;
header("Location: $location&message=success");//for redirecting it to detail page with message
}
?>