-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeed.php
89 lines (75 loc) · 1.89 KB
/
speed.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
78
79
80
81
82
83
84
85
86
87
88
89
<?php
require_once('includes/speed.php');
require_once('includes/camelCase.php');
// Default empty variables
$fromValue = '';
$fromUnit = '';
$toUnit = '';
$toValue = '';
/* Check conversion request on submit */
if ($_POST['submit']) {
$fromValue = $_POST['fromValue'];
$fromUnit = $_POST['fromUnit'];
$toUnit = $_POST['toUnit'];
$toValue = convertSpeed($fromValue, $fromUnit, $toUnit);
}
$speedUnits = array(
"feet per second",
"miles per hour",
"meters per second",
"kilometers per hour",
"knots"
);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Convert Speed</title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="main-content">
<h1>Convert Speed</h1>
<form action="" method="post">
<div class="entry">
<label>From:</label>
<input type="text" name="fromValue" value="<?php { echo $fromValue;} ?>" />
<select name="fromUnit">
<?php
foreach ($speedUnits as $unit) {
echo "<option value=\"" . camelCase($unit) . "\"";
if ($fromUnit == camelCase($unit)) {
{
echo " selected";
}
}
echo ">" . ucwords($unit) . "</option>";
}
?>
</select>
</div>
<div class="entry">
<label>To:</label>
<input type="text" name="toValue" value="<?php { echo $toValue;} ?>" />
<select name="toUnit">
<?php
foreach ($speedUnits as $unit) {
echo "<option value=\"" . camelCase($unit) . "\"";
if ($toUnit == camelCase($unit)) {
{
echo " selected";
}
}
echo ">" . ucwords($unit) . "</option>";
}
?>
</select>
</div>
<input type="submit" name="submit" value="Submit" />
</form>
<br/>
<a href="index.php">Return to menu</a>
</div>
</body>
</html>