I’m creating a simple temp conversion from Celsius to Fahrenheit with a drop down menu. Having a slight problem with it not outputting anything, not sure what I am missing here.
Any help would be appreciated.
<?php
//defining variable from the post form
$c2f = $_POST['degree']*9/5+32;
$f2c = ($_POST['degree']-32)*5/9;
$scale = $_POST['scale'];
if (isset($_POST['degree'])) {
$c2f = $_POST['degree']*9/5+32;
$f2c = ($_POST['degree']-32)*5/9;
if ($_POST['degree'] == "") {
echo "Error: Please input a degree";
}
}
if ($scale === "Celsius"){
echo "Fahrenheit is " . $c2f;
}
if ($scale === "Fahrenheit") {
echo "Celsius: " . $f2c;
}
?>
<html>
<head>
<title>Temperature Conversion</title>
<link rel="stylesheet" href="assets/style.css" />
</head>
<body>
<div class="container" />
<form action = "" method ="post">
<h4>Temperature Conversion</h4>
<p>Degrees:
<input type="text" name="degree" size="4" />
<select name="scale"> <option value="celsius">Celsius</option>
<option value="fahrenheit">Fahrenheit</option>
</select>
</p>
<p>
<input type="Submit" />
</p>
</form>
</div>
</body>
</html>