[PROBLEM SOLVED]
I'm working on a mini PHP project. It's a calculator (as stated in the title). For some reason, it isn't working correctly. It isn't doing the calculations properly, my code is provided below.
Link -
www.neo-productions.com/test/php/calculator.php
Example of use - 1 [First Input Box] - [Second Input Box] 1 [Third Input Box]
calculator.php
Code:
<html>
<!-- BEGIN Header Information (Title, Style, ETC) -->
<head>
<style type="text/css">
<!--
input.integer_feild {
width: 20px;
text-align: center;
}
input.operation_feild {
width: 15px;
text-align: center;
}
-->
</style>
<title>Neo Productions - PHP Calculator</title>
</head>
<!-- END Header Information -->
<!-- BEGIN Body Information -->
<body>
<!-- First Feild -->
<form method="post" action="calculate.php">
<input class="integer_feild" type="text" name="First_Feild"/>
<!-- Operation Feild -->
<input class="operation_feild" type="text" name="Operation_Feild"/>
<!-- Second Feild -->
<input class="integer_feild" type="text" name="Second_Feild"/>
<!-- Calculate Button -->
<input type="submit" name="Calculate" value="Calculate"/>
</form>
</body>
<!-- END Body Information -->
</html>
calculate.php
Code:
<html>
<head>
</head>
<body>
<?
#BEGIN Variable Declarations & Initializations.
$First_Integer = $_POST['First_Feild'];
$Operator = $_POST['Operation_Feild'];
$Second_Integer = $_POST['Second_Feild'];
#END Variable Declarations & Initializations.
switch ($Operator){
#If $Operator is equal to "/" then divide $First_Integer by $Second_Integer.
case "/":
echo ($First_Integer / $Second_Integer);
#If $Operator is equal to "*" then multiply $First_Integer by $Second_Integer.
case "*":
echo ($First_Integer * $Second_Integer);
#If $Operator is equal to "-" then subtract $Second_Integer from $First_Integer.
case "-":
echo ($First_Integer - $Second_Integer);
#If $Operator is equal to "+" then add $First_Integer and $Second_Integer.
case "+":
echo ($First_Integer + $Second_Integer);
}
?>
</body>
</html>
All suggestions will be highly valued. Thank you!
- Neo