-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbudget.php
38 lines (34 loc) · 1.12 KB
/
budget.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
<?php
require_once("Models/BudgetDb.php");
$view = new stdClass();
$view->pageTitle='Budget';
$errors = array();
$success = false;
$budgetDatabase = new BudgetDb();
if (isset($_POST["submit"])) {
$emailValidation = $_POST['email'];
$electrictyValidation = $_POST['electricityPrice'];
$gasValidation = $_POST['gasPrice'];
if ($emailValidation != '[email protected]') {
array_push($errors, "Email is incorrect.");
} else {
$data = array("electricityPrice" => $_POST["electricityPrice"],
"gasPrice" => $_POST["gasPrice"],
"email" => $_POST["email"],
"date" => $_POST["day"] . "-" . $_POST["month"] . "-" . $_POST["year"]);
$budgetDatabase->insert($data);
$success = true;
}
}
if (isset($_POST['cancel']) || isset($_POST['return'])) {
header("location: index.php");
}
$budget2 = $budgetDatabase->getBudget("[email protected]");
$electricPrice = $budget2["electricityPrice"];
$gasPrice = $budget2["gasPrice"];
$date = $budget2['date'];
if ($success) {
require_once("Views/seeBudget.phtml");
} else {
require_once("Views/budget.phtml");
}