-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.php
134 lines (110 loc) · 4.75 KB
/
transaction.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
<?php
session_start();
//echo $_SESSION['fromID'].'-->'.$_SESSION['toID'].'='.$_POST['amount'];
$amount=$_POST['amount'];
//echo $amount;
if(!isset($_POST['amount'])){
header('loaction: amount.php');
}
if(!isset($_SESSION['fromID'])||!isset($_SESSION['toID'])){
header('location: view.php');
}
?>
<?php
$fromID=$_SESSION['fromID'];
$toID=$_SESSION['toID'];
include('abcd.php');
$query="select balance,fname from customer where ID='$fromID' ";
$run=mysqli_query($con,$query);
$data=mysqli_fetch_assoc($run);
$amountA=$data['balance'];
$sendername=$data['fname'];
$query="select balance,fname from customer where ID='$toID' ";
$run=mysqli_query($con,$query);
$data=mysqli_fetch_assoc($run);
$amountB=$data['balance'];
$receivername=$data['fname'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Bank Management System- Index</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Montserrat:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/aos/aos.css" rel="stylesheet">
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<!-- ======= Hero Section ======= -->
<section id="hero">
<div class="hero-container">
<a href="index.html" class="hero-logo" data-aos="zoom-in"><img src="assets/img/2.png" alt=""></a>
<h1 data-aos="zoom-in">Bank Management System</h1>
</div>
</section><!-- End Hero -->
<!-- ======= Featured Section ======= -->
<section id="featured" class="featured">
<div class="container">
<div class="row">
<?php
if($amount>$amountA){
?>
<div class="alert alert-danger" role="alert">
Insuffecient Balance. Transaction Ended.<a href="view.php" class="alert-link">Go Back</a>.
</div>
<?php
}else{
$query="insert into transfer (fromID, toID, amount) values ('$fromID','$toID','$amount') ";
$run=mysqli_query($con,$query);
$amountA=$amountA-$amount;
$amountB=$amountB+$amount;
$query="update customer set balance='$amountA' where ID='$fromID' ";
$run=mysqli_query($con,$query);
$query="update customer set balance='$amountB' where ID='$toID' ";
$run=mysqli_query($con,$query);
?>
<div class="alert alert-success" role="alert">
Balance of Sender (<?php echo $sendername; ?>): <?php echo $amountA; ?>
<br>
Balance of Receiver (<?php echo $receivername; ?>): <?php echo $amountB; ?>
<br>
Transaction Successful <a href="view.php" class="alert-link">Click</a>, to process another transaction.
</div>
<?php
}
?>
</div>
</div>
</section><!-- End Featured Section -->
<!-- ======= Footer ======= -->
<footer id="footer">
<div class="container footer-bottom clearfix">
<div class="copyright">
© Copyright <strong><a href="https://github.com/apoorvgit"><span>ApoorvGit</span></a></strong>. All Rights Reserved
</div>
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/aos/aos.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/swiper/swiper-bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>