I have a form like this
<html>
<body>
<form action="calc.php" method="post">
Primo numero: <input type="text" name="a" /></br>
Operazione (+-*/): <input type="text" name="b" /></br>
Secondo numero: <input type="text" name="c" />
<input type="submit" />
</form>
</body>
</html>
lied to a separate .php file named calc.php
that is like
<?php echo $_POST["a"]; ?><?php echo $_POST["b"]; ?><?php echo $_POST["c"]; ?><strong>=</strong>
<?php
if ($_POST["b"] == "+")
{
echo $_POST["a"] + $_POST["c"];
}
if ($_POST["b"] == "-")
{
echo $_POST["a"] - $_POST["c"];
}
if ($_POST["b"] == "*")
{
echo $_POST["a"] * $_POST["c"];
}
if ($_POST["b"] == "/")
{
echo $_POST["a"] / $_POST["c"];
}
?>
It works fine but I'd like to show the result in the same page
How can I do?
You can put the code in the same file and change the form to:
or
to submit it to the same page.