-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselecting_users.php
223 lines (174 loc) · 7.5 KB
/
selecting_users.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
212
213
214
215
216
217
218
219
220
221
222
223
<?php
include 'connect_backend.php';
if(isset($_POST['submit']))
{
$from = $_GET['id'];
$to = $_POST['to'];
$amount = $_POST['amount'];
$sql = "SELECT * from customers where id=$from";
$query = mysqli_query($conn,$sql);
$sql1 = mysqli_fetch_array($query);
$sql = "SELECT * from customers where id=$to";
$query = mysqli_query($conn,$sql);
$sql2 = mysqli_fetch_array($query);
if (($amount)<0)
{
echo '<script type="text/javascript">';
echo ' alert("Oops! Negative values cannot be transferred")'; // showing an alert box.
echo '</script>';
}
// constraint to check insufficient balance.
else if($amount > $sql1['balance'])
{
echo '<script type="text/javascript">';
echo ' alert("Bad Luck! Insufficient Balance")'; // showing an alert box.
echo '</script>';
}
// constraint to check zero values
else if($amount == 0){
echo "<script type='text/javascript'>";
echo "alert('Oops! Zero value cannot be transferred')";
echo "</script>";
}
else {
$newbalance = $sql1['balance'] - $amount;
$sql = "UPDATE customers set balance=$newbalance where id=$from";
mysqli_query($conn,$sql);
$newbalance = $sql2['balance'] + $amount;
$sql = "UPDATE customers set balance=$newbalance where id=$to";
mysqli_query($conn,$sql);
$sender = $sql1['c_name'];
$receiver = $sql2['c_name'];
$sql = "INSERT INTO transaction(`Sender_name`, `Receiver`, `balance`) VALUES ('$sender','$receiver','$amount')";
$query=mysqli_query($conn,$sql);
if($query){
echo "<script> alert('Transaction Successful');
window.location='reciept.php';
</script>";
}
$newbalance= 0;
$amount =0;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, intital-scale=1.0">
<title>Transaction</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/nav.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
button{
border:none;
background:#d9d9d9;
}
input["text"],input["number"]{
background-color:skyblue;
}
button:hover{
background-color:#777E8B;
transform: scale(1.1);
color:white;
}
</style>
</head>
<body>
<div class="topnav" id="myTopnav">
<a class="brand" href="index.html"><i><b>Easy Transfer</b></i></a>
<a href="index.html" ><b>Home</b></a>
<a href="transfer_hist.php" ><i ></i><b>Transaction History</b></a>
<a href="customer_details.php" ><i> </i><b>Customers Details</b></a>
<a href="index.html#aboutus"><b>About Us</b></a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<section class="section-bg">
<div class="section-title" data-aos="fade-up">
<p> Welcome To Transfer Page</p>
</div>
<?php
include 'connect_backend.php';
$sid=$_GET['id'];
$sql = "SELECT * FROM customers where id=$sid";
$result=mysqli_query($conn,$sql);
if(!$result)
{
echo "Error : ".$sql."<br>".mysqli_error($conn);
}
$rows=mysqli_fetch_assoc($result);
?>
<form method="post" name="tcredit" class="tabletext" ><br>
<div>
<center>
<h3>Sender Information</h3>
<b><p>Full Name:<?php echo $rows['c_name'] ?></p></b>
<b><p>Email:<?php echo $rows['email'] ?></p></b>
<b><p>Country:<?php echo $rows['country']?></p></b>
<b><p>Balance:<?php echo $rows['balance'] ?></p></b>
</center>
</div>
<div class="container">
<br><br><br>
<h3><p class="section-title" data-aos="fade-up">Transfer To</p></h3>
<select name="to" class="form-control" required>
<option value="" disabled selected>Choose</option>
<?php
include 'connect_backend.php';
$sid=$_GET['id'];
$sql = "SELECT * FROM customers where id!=$sid";
$result=mysqli_query($conn,$sql);
if(!$result)
{
echo "Error ".$sql."<br>".mysqli_error($conn);
}
while($rows = mysqli_fetch_assoc($result)) {
?>
<option class="table" value="<?php echo $rows['id'];?>" >
<?php echo $rows['c_name'] ;?>
</option>
<?php
}
?>
<div>
</select>
<br>
<br>
<label><b>Amount:</b></label>
<input type="number" class="form-control" name="amount" required>
<br><br>
<div class="text-center" >
<button class="btn mt-3 btn btn-success" name="submit" type="submit" id="myBtn">Transfer</button>
</div>
</form>
</div>
</section>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
<br>
<footer>
<div>
<a href="https://www.youtube.com/"><i class="fa fa-youtube-play" style="color:white"></i></a>
<a href="https://www.linkedin.com/in/darshan-khaire-561476207"><i class="fa fa-linkedin-square" style="color:white"></i></a>
<a href="https://www.google.com/"><i class="fa fa-google" style="color:white"></i></a>
<a href="https://github.com/darshankk-ui"><i class="fa fa-github" style="color:white"></i></a>
</div>
<small>© Copyright 2021, Darshan Khaire</small>
<br>
</footer>
</body>
</html>