/
addBudget.php
77 lines (74 loc) · 1.67 KB
/
addBudget.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
$con=new mysqli('localhost','octo','w3b7ysX6','octo');
if($con->connect_error){
die("Connection failed");
}
session_start();
$isLoggedIn = false;
if(isset($_SESSION['user'])){
$isLoggedIn =true;
$u = $_SESSION['user'];
}
$years = array();
$year = 2017;
if($stmt=$con->prepare("SELECT DISTINCT year FROM finances WHERE username = ?")){
$stmt->bind_param("s",$username);
$username=$u;
//set username to session attribute
$stmt->execute();
$stmt->bind_result($a);
while($stmt->fetch()){
//echo $a;
array_push($years,$a);
}
$stmt->close();
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="processBudget.php">
<select name = "month">
<option disabled>Choose Month</option>
<option >January</option>
<option >February</option>
<option >March</option>
<option >April</option>
<option >May</option>
<option >June</option>
<option >July</option>
<option >August</option>
<option >September</option>
<option >October</option>
<option >November</option>
<option >December</option>
</select>
<br>
<select name = "year">
<?php
for($i = 0; $i < count($years); $i++){
echo '<option>'.$years[$i].'</option>';
}
?>
</select>
<br>
Income
<input type="text" name="income" placeholder="Enter Amount Here">
<br>
Rent
<input type="text" name="rent" placeholder="Enter Amount Here">
<br>
Food
<input type="text" name="food" placeholder="Enter Amount Here">
<br>
Clothing
<input type="text" name="clothing" placeholder="Enter Amount Here">
<br>
Entertainment
<input type="text" name="entertainment" placeholder="Enter Amount Here">
<br>
<input type="submit" value="Submit" placeholder="Enter Amount Here">
</form>
</body>
</html>