crear caculadora php
<html>
    <head><title> operaciones basicas
          </title>
    </head>
<body>
Calculadora <br>
<form   action="resultado.php" method="post" >
ingrese primer numero
<input type="text" name="num1" />
<select name="ope">
<option values="+"> + </option>
<option values="-"> - </option>
<option values="*"> * </option>
<option values="/"> / </option>
</select>

ingrese segundo numero
<input type="text" name="num2" />
<input type="reset" value="borrar" />
<input type="submit" value="calcular" />
<?php
if(!empty($_POST)){
if ($_POST ["num1"] != "" and $_POST ["num2"] != "")
{ $op=$_POST["ope"];
 $n1=$_POST["num1"];
 $n2=$_POST["num2"];
 switch ($op)
{ case "+": echo ($sum=$n1+$n2);break;
  case "-": echo ($res=$n1-$n2);break;
  case "*": echo ($mul=$n1*$n2);break;
  case "/": echo ($div=$n1/$n2);break;
 }
}
else
  {echo ("debe ingresar un numero");
   echo ('<br><a href="resultado" >volver</a>');
       }
  }
?>
</form>
</body>
</html>

Share this

Related Posts

Previous
Next Post »