Below I made a basic calculator that adds, subtracts, divides, and multiplies. The issue is, when I submit the values the results do not “echo” on the page. Below is the code i have created. Hoping someone can assist me with this one.
<html>
<body>
<form action = "site.php" method="post">
First number: <input type="number" name="digit1"> <br>
OP: <input type="text" name="op"> <br>
Second number: <input type="number" name="digit2"> <br>
<input type="submit"><br>
</form>
<?php
$digit1 = $_Post["digit1"];
$digit2 = $_Post["digit2"];
$op = $_Post["op"];
if($op == "+"){
echo $digit1 + $digit2;
} elseif($op == "-"){
echo $digit1 - $digit2;
}elseif($op == "*"){
echo $digit1 * $digit2;
}elseif($op == "/"){
echo $digit1 / $digit2;
}else{
echo "invalid operator";
}
?>
</body>
</html>