I'm just doing a rather lame calculator as I am beginning to learn PHP. I can't figure out why everything seems to be fine except the answer will not display.
Here's the HTML:
<head>
<meta charset="utf-8">
<title>A (Seriously) Simple Calculator</title>
<link rel="stylesheet" type="text/css" href="./calc_css.css">
</head>
<body>
<form method="post" attribute="post" action="calc1.php">
<p>First Value:<br/>
<input type="number" id="first" name="first" step="0.0000000001"></p>
<p>Second Value:<br/>
<input type="number" id="second" name="second" step="0.0000000001"></p>
<p>+<input type="radio" name="operation" id="add" value="add" checked="true"></p><br/>
<p>-<input type="radio" name="operation" id="subtract" value="subtract"></p><br/>
<p>X<input type="radio" name="operation" id="multiply" value="multiply"></p><br/>
<p>/<input type="radio" name="operation" id="divide" value="divide"></p><br/>
<p></p>
<button type="submit" name="answer" id="answer" value="answer">Calculate</button>
</form>
</body>
</html>
And here's my PHP:
<html>
<head>
<meta charset="utf-8">
<title>Answer</title>
</head>
<body>
<p>The answer is:
<?php
$first = floatval($_POST['first']);
$second = floatval($_POST['second']);
if($_POST['operation'] == 'add') {
echo $first + $second;
}
else if($_POST['operation'] == 'subtract') {
echo $first - $second;
}
else if($_POST['operation'] == 'multiply') {
echo $first * $second;
}
else($_POST['operation'] == 'divide') {
echo $first / $second;
}
?>
</p>
</body>
</html>
I don't think it has to do with my input step or type, and I've tried all manner of things (that I can think of) in my PHP file. That said, I am a very green beginner. Any help would be greatly appreciated.