-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransfer.php
More file actions
232 lines (198 loc) · 6.62 KB
/
transfer.php
File metadata and controls
232 lines (198 loc) · 6.62 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
226
227
228
229
230
231
232
<?php
include 'config.php';
if(isset($_POST['submit']))
{
$from = $_GET['id'];
$toUser = $_POST['to'];
$amnt = $_POST['amount'];
$sql = "SELECT * from users where id=$from";
$query = mysqli_query($conn,$sql);
$sql1 = mysqli_fetch_array($query);
$sql = "SELECT * from users where id=$toUser";
$query = mysqli_query($conn,$sql);
$sql2 = mysqli_fetch_array($query);
if($amnt > $sql1['amount'])
{
echo '<script type="text/javascript">';
echo ' alert("Insufficient Balance")';
echo '</script>';
}
else if($amnt == 0){
echo "<script type='text/javascript'>alert('Enter Amount Greater than Zero');
</script>";
}
else {
$newCredit = $sql1['amount'] - $amnt;
$sql = "UPDATE users set amount=$newCredit where id=$from";
mysqli_query($conn,$sql);
$newCredit = $sql2['amount'] + $amnt;
$sql = "UPDATE users set amount=$newCredit where id=$toUser";
mysqli_query($conn,$sql);
$sender = $sql1['name'];
$receiver = $sql2['name'];
$sql = "INSERT INTO transaction(`remitter`, `beneficiary`, `amount`) VALUES ('$sender','$receiver','$amnt')";
$tns=mysqli_query($conn,$sql);
if($tns){
echo "<script type='text/javascript'>
alert('Transaction Successful !');
window.location='transaction.php';
</script>";
}
$newCredit= 0;
$amnt =0;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Transfer Credits</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
.sidenav {
height: 100%;
width: 160px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
padding-top: 20px;
}
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
}
.sidenav a:hover {
color: #f1f1f1;
}
.button {
background-color: #0b2d4e;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 18px;
margin: 0px 2px;
border-radius: 5px;
}
.button:hover{
background-color: #7cafe1;
color: #10002b;
}
.button:active{
background-color: #2ec4b6;
}
h2{
text-align: center;
margin-top: 15px;
}
.form-control{
color:black;
}
.form-control.hover{
color:black;
}
h2{
font-family: sans-serif;
color: #03045e;
font-weight: bold;
}
th, td{
font-family: opensans;
font-size: 18px;
font-weight: 20pt;
}
label {
font-family: opensans;
font-weight: bold;
color: #651838;
font-size: 20px;
}
</style>
</head>
<body style=
"
background-repeat: no-repeat;
background-attachment: fixed;
width: 100%; background-position: center;">
<div class="sidenav">
<a href="main.html">Home</a>
<a href="users.php">Customer List</a>
<a href="transaction.php">History</a>
</div>
<div class="container divStyle">
<?php
include 'config.php';
$sid=$_GET['id'];
$sql = "SELECT * FROM users where id=$sid";
$query=mysqli_query($conn,$sql);
if(!$query)
{
echo "Error ".$sql."<br/>".mysqli_error($conn);
}
$rows=mysqli_fetch_array($query);
?>
<form method="post" name="tcredit" class="tabletext" ><br/>
<label> FROM: </label><br/>
<div>
<table class="table roundedCorners tabletext table-hover table-striped table-condensed" >
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Amount Transferred</th>
</tr>
<tr>
<td><?php echo $rows['id'] ?></td>
<td><?php echo $rows['name'] ?></td>
<td><?php echo $rows['email'] ?></td>
<td><?php echo $rows['amount'] ?></td>
</tr>
</table>
</div>
<br/>
<label>TO:</label>
<select class=" form-control" name="to" style="margin-bottom:5%;" required>
<option value="" disabled selected> </option>
<?php
include 'config.php';
$sid=$_GET['id'];
$sql = "SELECT * FROM users where id!=$sid";
$query=mysqli_query($conn,$sql);
if(!$query)
{
echo "Error ".$sql."<br/>".mysqli_error($conn);
}
while($rows = mysqli_fetch_array($query)) {
?>
<option class="table text-center table-striped " value="<?php echo $rows['id'];?>" >
<?php echo $rows['name'] ;?>
<!--(Credits:
<?php echo $rows['amount'] ;?> )-->
</option>
<?php
}
?>
</select>
<label>AMOUNT:</label>
<input type="number" id="amm" class="form-control" name="amount" min="0" required /> <br/><br/>
<div class="text-center btn3" >
<button class="button" name="submit" type="submit" id="myBtn" style="margin:8px;">TRANSFER</button>
<button class="button" name="reset" type="reset" id="myBtn" style="margin:8px;">RESET</button>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>