-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_transfer.php
56 lines (55 loc) · 1.99 KB
/
view_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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transaction Record</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
include 'connect.php';
$amount=$_POST['amount'];
$to=$_POST['receiver'];
$from = $_POST['from'];
$query="SELECT `name` from customers WHERE ID=$to";
$conn=mysqli_query($db_connect,$query);
$row=mysqli_fetch_assoc($conn);
$receiver=$row['name'];
$query="SELECT `name` from customers WHERE ID=$from";
$conn=mysqli_query($db_connect,$query);
$row=mysqli_fetch_assoc($conn);
$sender=$row['name'];
$query="UPDATE customers SET balance=balance+$amount where ID=$to";
$conn=mysqli_query($db_connect,$query);
$query="UPDATE customers SET balance=balance-$amount where ID=$from";
$conn=mysqli_query($db_connect,$query);
$query = "INSERT INTO `transfer` (`sender`, `reciever`, `amount`) VALUES ('$sender','$receiver','$amount') ";
$conn = mysqli_query($db_connect,$query);
echo"<script>alert('Transaction Successful!')</script>";
?>
<h1> Transactions: </h1>
<table style='text-align:center; font-size: x-large;'>
<tr>
<th>From</th>
<th>To</th>
<th>Amount</th>
</tr>
<?php
$query = "SELECT * from `transfer`";
$conn = mysqli_query($db_connect,$query);
while($row = mysqli_fetch_assoc($conn)){
echo"
<tr>
<td>".$row['sender']."</td>
<td>".$row['reciever']."</td>
<td>".$row['amount']."</td></tr>";
}
}
?>
</table>
<a href="./customer.php"><button>View All Customers</button></a>
</body>
</html>