pagina1.html
<html>
<head>
<title>Problema</title>
</head>
<body>
<form action="pagina2.php"
method="post">
Ingrese primer valor:
<input type="text"
name="valor1">
<br>
Ingrese segundo valor:
<input type="text"
name="valor2">
<br>
<select name="operacion">
<option
value="suma">sumar</option>
<option
value="resta">restar</option>
</select>
<br>
<input type="submit" name="operar">
</form>
</body>
</html>
<select
name="operacion">
<option value="suma">sumar</option>
<option value="resta">restar</option>
</select>
<html>
<head>
<title>Problema</title>
</head>
<body>
<?php
if ($_REQUEST['operacion'] ==
"suma") {
$suma = $_REQUEST['valor1'] +
$_REQUEST['valor2'];
echo "La suma es:" . $suma;
} else {
if ($_REQUEST['operacion'] == "resta")
{
$resta = $_REQUEST['valor1'] -
$_REQUEST['valor2'];
echo "La resta es:" . $resta;
}
}
?>
</body>
</html>
if ($_REQUEST['operacion'] ==
"suma") {
$suma = $_REQUEST['valor1'] + $_REQUEST['valor2'];
echo "La suma es:" . $suma;
} else {
if ($_REQUEST['operacion'] == "resta") {
$resta = $_REQUEST['valor1'] - $_REQUEST['valor2'];
echo "La resta es:" . $resta;
}
}
Comentarios
Publicar un comentario