-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.php
63 lines (60 loc) · 3.19 KB
/
connection.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
<?php
//This connection.php file will submit the form data from index.html to the Database based on the current month
//[Error Handling]error_reporting(E_ALL); ini_set('display_errors', 1);
include_once 'dbconnect/db_info.php';
$weight = $_POST['weight'];
$person = $_POST['person'];
$date = $_POST['weightdate'];
$formatDate = date("d/m/y", strtotime($date));
if(date("m", strtotime($date)) == date("01")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'January');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("02")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'February');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("03")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'March');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("04")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'April');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("05")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'May');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("06")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'June');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("07")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'July');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("08")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'August');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("09")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'September');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("10")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'October');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("11")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'November');";
$result = mysqli_query($conn, $sql);
}
elseif(date("m", strtotime($date)) == date("12")) {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date, date_month) VALUES ('$person', '$weight', '$formatDate', 'December');";
$result = mysqli_query($conn, $sql);
}
else {
$sql = "INSERT INTO WeightTracker (person, kg, weight_date) VALUES ('$person', '$weight', '$date');";
$result = mysqli_query($conn, $sql);
}