volume.php
8.21 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
if (file_exists('dbconnect.php')) {
require('dbconnect.php');
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ')' . mysqli_connect_error());
}
}
//Add function file
if (file_exists('../includes/functions.php')) {
require_once('../includes/functions.php');
} else {
echo "Unsupported File";
}
$from_value = '';
$from_unit = '';
$to_unit = '';
$to_value = '';
if ($_POST['submit']) {
$from_value = $_POST['from_value'];
$from_unit = $_POST['from_unit'];
$to_unit = $_POST['to_unit'];
$to_value = convert_volume($from_value, $from_unit, $to_unit);
$sql = "INSERT INTO volume_entry(from_unit,to_unit,from_value,to_value) VALUES ('$from_unit','$to_unit','$from_value','$to_value');";
if (!mysqli_query($link, $sql)) {
die('An error occurred when submitting your review.');
}
}
$volume_options = array(
'cubic inches',
'cubic feet',
'Imperial gallons',
'Imperial quarts',
'Imperial pints',
'Imperial cups',
'Imperial ounces',
'Imperial tablespoons',
'Imperial teaspoons',
'US gallons',
'US quarts',
'US pints',
'US cups',
'US ounces',
'US tablespoons',
'US teaspoons',
'cubic centimeters',
'cubic meters',
'liters',
'milliliters'
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/simp-Volume.css" />
<title>Convert Volume</title>
</head>
<body>
<!--This is the simpler version,
supposed to have-
>a top title
>a side bar menu
>calculator with input,output,reset button-->
<nav class="navbar">
<span class="open-slide">
<a href="#" onclick="openSlideMenu()">
<svg width="30" height="30">
<path d="M0,5 30,5" stroke="#000" stroke-width="5" />
<path d="M0,14 30,14" stroke="#000" stroke-width="5" />
<path d="M0,23 30,23" stroke="#000" stroke-width="5" />
</svg>
</a>
</span>
</nav>
<div id="side-menu" class="side-nav">
<a href="#" class="btn-close" onclick="closeSlideMenu()">×</a>
<a href="categories/length.php">Length</a>
<a href="categories/temperature.php">Temperature</a>
<a href="categories/area.php">Area</a>
<a href="categories/volume.php">Volume</a>
<a href="categories/weight.php">Weight</a>
<a href="categories/speed.php">Speed</a>
<a href="login/login.php">Log in</a>
</div>
<script src="../js/slide.js"></script>
<div id="title">
<h1>Volume</h1>
</div>
<!-- top---->
<div class="calculator">
<!--whole calculator outline-->
<div class="calcb">
<!--Calculator box -->
<div id="sinput" class="input">
<form action="" method="post">
<div class="entry">
<input id="Input" class="Input-text" placeholder="Enter amount" name="from_value" value="<?php echo $from_value; ?>" />
<label for="Input" class="Input-label">Your entry</label>
<select name="from_unit">
<option value="cubic_inches"<?php if($from_unit == 'cubic_inches') { echo " selected"; } ?>>cubic inches</option>
<option value="cubic_feet"<?php if($from_unit == 'cubic_feet') { echo " selected"; } ?>>cubic feet</option>
<option value="cubic_meters"<?php if($from_unit == 'cubic_meters') { echo " selected"; } ?>>cubic meters</option>
<option value="cubic_centimeres"<?php if($from_unit == 'cubic_centimeters') { echo " selected"; } ?>>cubic centimeters</option>
<option value="imperial_gallons"<?php if($from_unit == 'imperial_gallons') { echo " selected"; } ?>>imperial gallons</option>
<option value="imperial_quarts"<?php if($from_unit == 'imperial_quarts') { echo " selected"; } ?>>imperial quarts</option>
<option value="imperial_pints"<?php if($from_unit == 'imperial_pints') { echo " selected"; } ?>>imperial pints</option>
<option value="imperial_cups"<?php if($from_unit == 'imperial_cups') { echo " selected"; } ?>>imperial cups</option>
<option value="imperial_ounces"<?php if($from_unit == 'imperial_ounces') { echo " selected"; } ?>>imperial ounces</option>
<option value="imperial_tablespoons"<?php if($from_unit == 'imperial_tablespoons') { echo " selected"; } ?>>imperial tablespoons</option>
<option value="us_gallons"<?php if($from_unit == 'us_gallons') { echo " selected"; } ?>>US gallons</option>
<option value="us_quarts"<?php if($from_unit == 'imperial_quarts') { echo " selected"; } ?>>imperial quarts</option>
<option value="us_pints"<?php if($from_unit == 'imperial_pints') { echo " selected"; } ?>>imperial pints</option>
<option value="us_cups"<?php if($from_unit == 'us_cups') { echo " selected"; } ?>>US cups</option>
<option value="us_ounces"<?php if($from_unit == 'us_ounces') { echo " selected"; } ?>>US ounces</option>
<option value="us_tablespoons"<?php if($from_unit == 'us_tablespoons') { echo " selected"; } ?>>US tablespoons</option>
<option value="us_gallons"<?php if($from_unit == 'us_gallons') { echo " selected"; } ?>>US gallons</option>
<option value="liters"<?php if($from_unit == 'liters') { echo " selected"; } ?>>liters</option>
<option value="millimeters"<?php if($from_unit == 'millimeters') { echo " selected"; } ?>>millimeters</option>
</select>
</div>
<div class="entry">
<input readonly id="Input" class="Input-text" placeholder="Wait for it" name="to_value" value=" <?php echo $to_value; ?>" />
<label for="Input" class="input-label">Converted Result</label>
<select name="to_unit">
<option value="cubic_inches"<?php if($to_unit == 'cubic_inches') { echo " selected"; } ?>>cubic inches</option>
<option value="cubic_feet"<?php if($to_unit == 'cubic_feet') { echo " selected"; } ?>>cubic feet</option>
<option value="cubic_meters"<?php if($tounit == 'cubic_meters') { echo " selected"; } ?>>cubic meters</option>
<option value="cubic_centimeres"<?php if($to_unit == 'cubic_centimeters') { echo " selected"; } ?>>cubic centimeters</option>
<option value="imperial_gallons"<?php if($to_unit == 'imperial_gallons') { echo " selected"; } ?>>imperial gallons</option>
<option value="imperial_quarts"<?php if($to_unit == 'imperial_quarts') { echo " selected"; } ?>>imperial quarts</option>
<option value="imperial_pints"<?php if($to_unit == 'imperial_pints') { echo " selected"; } ?>>imperial pints</option>
<option value="imperial_cups"<?php if($to_unit == 'imperial_cups') { echo " selected"; } ?>>imperial cups</option>
<option value="imperial_ounces"<?php if($to_unit == 'imperial_ounces') { echo " selected"; } ?>>imperial ounces</option>
<option value="imperial_tablespoons"<?php if($to_unit == 'imperial_tablespoons') { echo " selected"; } ?>>imperial tablespoons</option>
<option value="us_gallons"<?php if($to_unit == 'us_gallons') { echo " selected"; } ?>>US gallons</option>
<option value="us_quarts"<?php if($to_unit == 'imperial_quarts') { echo " selected"; } ?>>imperial quarts</option>
<option value="us_pints"<?php if($to_unit == 'imperial_pints') { echo " selected"; } ?>>imperial pints</option>
<option value="us_cups"<?php if($to_unit == 'us_cups') { echo " selected"; } ?>>US cups</option>
<option value="us_ounces"<?php if($to_unit == 'us_ounces') { echo " selected"; } ?>>US ounces</option>
<option value="us_tablespoons"<?php if($to_unit == 'us_tablespoons') { echo " selected"; } ?>>US tablespoons</option>
<option value="us_gallons"<?php if($to_unit == 'us_gallons') { echo " selected"; } ?>>US gallons</option>
<option value="liters"<?php if($to_unit == 'liters') { echo " selected"; } ?>>liters</option>
<option value="millimeters"<?php if($to_unit == 'millimeters') { echo " selected"; } ?>>millimeters</option>
</select>
</div>
<input type="submit" name="submit" value="Submit" />
</form>
</div>
</div>
</div>
</div>
</body>
</html>