-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddbalance.php
29 lines (29 loc) · 1.28 KB
/
addbalance.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
<?php
if (isset($_POST['money'])) {
$amount = $_POST['money'];
if ($amount >= 0) {
$currentbalance = "";
include("db-connection.php");
foreach ($balances as $id => $balance) {
foreach ($balance as $value) {
$currentbalance = $value;
}
}
if ($currentbalance < 500) {
$currentbalance += $amount;
$sql = "UPDATE user SET balance = '" . $currentbalance . "' WHERE login = '" . $_SESSION['username'] . "'";
if ($db->query($sql) === TRUE) {
echo "<div class='alert alert-success' role='alert'><h3 class='h4 mb-3'>🎈 Pomyślnie dodano środki!</h3></div>";
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Nie udało się dodać środków</h3></div>";
}
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Nie możesz już dodać więcej środków!</h3></div>";
}
mysqli_close($db);
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Nie możesz dodać ujemnych środków!</h3>";
echo "<h3 class='h5 mb-3'>📌 Wprowadź kwotę > 0</h3></div>";
echo "<br />";
}
}