imposta la pagina come segue, ma occhio ad altre imprecisioni che non voglio toglierti il piacere di scoprire.
Codice PHP:
<?php
if(!empty($_POST['Calcola'])) {
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$operazione = $_POST['operazione'];
switch($operazione){
case '+':
echo "$num1 + $num2 = " . $num1 + $num2;
break;
case '-':
echo "$num1 - $num2 = " . $num1 - $num2;
break;
case '*':
echo "$num1 * $num2 = " .$num1 * $num2;
break;
case '/':
echo "$num1 / $num2 = " . $num1 / $num2;
break;
}
}
?>
<html>
<head>
<title>Calcolatrice</title>
</head>
<body>
<form method="post" action="calcolatrice.php">
<table>
<tr>
<td><input name="num1" type="text"></td>
<td><select name="operazione" >
<option name="+" value="+"> + </option>
<option name="-" value="-"> - </option>
<option name="*" value="x"> x </option>
<option name="/" value="/"> ÷ </option>
</select></td>
<td><input name="num2" type="text"></td>
</tr>
<tr>
<td colspan="3">
<input type="submit" name="Calcola" value="Calcola"></td>
</tr>
</table>
</form>
</body>
</html>