-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.php
More file actions
47 lines (41 loc) · 1.05 KB
/
Copy pathconvert.php
File metadata and controls
47 lines (41 loc) · 1.05 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
<?php
/**
* Created by PhpStorm.
* @author Zachary Hughes <zhughes3@gmail.com>
* Date: 3/16/2016
* Time: 10:22 AM
* Description: A program to convert values between Fahrenheit and Celsius temperatures.
*/
include_once 'security.php';
$f = $c = '';
if (isset($_POST['f'])) {
$f = sanitizeString($_POST['f']);
}
if (isset($_POST['c'])) {
$c = sanitizeString($_POST['c']);
}
if ($f != '') {
$c = intval((5/9) * ($f - 32));
$out = "$f°f equals $c °c";
} elseif ($c != '') {
$f = intval((9/5) * $c + 32);
$out = "$c°c equals $f °f";
} else $out = "";
echo <<<_END
<html>
<head>
<title>Temperature Converter</title>
</head>
<body>
<pre>
Enter either Fahrenheit or Celsius and click on Convert
<b>$out</b>
<form method = "post" action = "convert.php">
Fahrenheit <input type = "text" name = "f" size = "7">
Celsius <input type = "text" name = "c" size = "7">
<input type = "submit" value = "Convert">
</form>
</pre>
</body>
</html>
_END;