-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
77 lines (68 loc) · 1.97 KB
/
dashboard.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
<?php
include('connect_user.php');
include('functions.php');
include('header.php');
checkUser();
userArea();
?>
<!DOCTYPE html>
<main class="dashboard">
<div class="box">
<h2>฿<?php echo calculateExpense('today')?></h2>
<p>Today's Expense</p>
</div>
<div class="box">
<h2>฿<?php echo calculateExpense('yesterday')?></h2>
<p>Yesterday's Expense</p>
</div>
<div class="box">
<h2>฿<?php echo calculateExpense('week')?></h2>
<p>This Week's Expense</p>
</div>
<div class="box">
<h2>฿<?php echo calculateExpense('month')?></h2>
<p>This Month's Expense</p>
</div>
<div class="box">
<h2>฿<?php echo calculateExpense('year')?></h2>
<p>This Year's Expense</p>
</div>
<div class="box">
<h2>฿<?php echo calculateExpense('total')?></h2>
<p>Total's Expense</p>
</div>
</main>
<?php if(isset($_POST['submit'])){
$amount = checkvalue($_POST['amount']);
$user_id = $_SESSION['UID'];
$sql = "UPDATE budget SET amount = '$amount' WHERE user_id = '$user_id'";
if ($con->query($sql) === TRUE) {
//$result = $con->query($sql);
mysqli_query($con, $sql);
}else{ $inputerror = "Wrong input!!!";}
}
?>
<h2 class="budget-heading"> Budget </h2>
<div class="budgetform-container">
<h2 class="inserturbud-heading"> Insert Monthly Budget</h2>
<form action="" method="POST">
<input type="text" name="amount">
<button type="submit" name="submit" value="Submit" class="submit-button">Submit</button>
</form>
<label class="budget-label"> Your Monthly Budget: ฿<?php echo getBudgetAmount()?></label>
<br/><br/>
<div class="boxbud">
<h2>฿<?php echo getBudgetAmount() - calculateExpense('month')?></h2>
<p>Remaining Budget</p>
<?php
if (isset($inputerror)) {
echo "<p style='color: red;'>$inputerror</p>";
} else { echo " ";}
?>
</div>
</div>
<footer>
<p>CSS326</p>
</footer>
</body>
</html>