-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.php
123 lines (96 loc) · 4.19 KB
/
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
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
<?php
require "partials/header.php";
?>
<body>
<link rel="stylesheet" href="static/css/transfer.css">
<?php
require 'partials/navbar.php';
// middle ware files
require "config/config.php";
require "sql/transferget.php";
?>
<?php
// checking if the server request is POST type then it will run the code
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// check max value if(amount>9500) throw error
$max = 9500;
// if the upi id is selected and the amount is in the range and the value is not 0
if ($_POST['upi'] === '@UPI' || $_POST['amount'] === '' || $_POST['amount'] > $max) {
echo '<div class= "container">
<div class="alert alert-warning alert-dismissible fade show">
<strong> Limit Warning!</strong> Cannot proceed with the transaction.
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
</div>';
// header("location:transfer2.php");
} else {
$upis = $_POST['upi'];
$amounts = $_POST['amount'];
$sql1 = "UPDATE contacts set balance=balance+'$amounts' where upi='$upis'";
$result1 = mysqli_query($conn, $sql1);
if ($result1) {
sleep(1);
// insert the form data to transaction table after updating the balance into test table
$sql2 = "INSERT INTO `transaction` ( `upi`, `amount`) VALUES ( '$upis', '$amounts');";
$result2 = mysqli_query($conn, $sql2);
if ($result2) {
sleep(1);
header("location:dashboard.php");
} else {
echo '<div class= "container">
<div class="alert alert-danger alert-dismissible fade show">
<strong>Database Error!</strong> Database Down
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
</div>';
}
} else {
echo '<div class= "container">
<div class="alert alert-danger alert-dismissible fade show">
<strong>Database Error! </strong> Database Down
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
</div>';
}
}
}
?>
<!-- Form-->
<div class="form">
<div class="form-toggle"></div>
<div class="form-panel one">
<div class="form-header">
<h1>Transfer Money</h1>
<h4 class="h4-heading">Take care of you and yours at home, and we can take care of you online.</h4>
</div>
<div class="form-content">
<form action="transfer.php" method="POST">
<div class="form-group">
<label for="username">Username</label>
<select required class="upi" name="upi">
<option> @UPI</option>
<?php
while ($row = mysqli_fetch_assoc($result)) {
$upid = $row['upi'];
?>
<!-- fetch record from db -->
<option value="<?php echo $upid ?>"> <?php echo $upid ?> </option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input id="amount" type="text" name="amount" required="required" />
</div>
<div class="form-group">
<button type="submit">Transfer</button>
</div>
</form>
</div>
</div>
</div>
<!-- footer -->
<?php
require 'partials/footer.php';
?>
<!-- footer end -->