Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/12/2013, 12:57
jesus_spanishteacher
 
Fecha de Ingreso: septiembre-2013
Mensajes: 76
Antigüedad: 10 años, 7 meses
Puntos: 0
Suma/multiplicación de 2 números

Hola, que tal a todos/as, he realizado el siguiente código, mi duda esta en la última parte; como pongo la condición para decir que si el usuario no introduce dos valores o introduce otro carácter, entonces le salga un mensaje de error:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>suma</title>
</head>

<body>


<?php
@ $x1=$_POST["x1"];
@ $x2=$_POST["x2"];
$y=$x1*$x2;
?>

<table align="center">
<thead> </thead>
<tbody>
<tr>
<th> </th>
<th> 1 </th>
<th> 2 </th>
</tr>
<tr>
<th> X </th>
<th> 1 </th>
<th> 4 </th>
</tr>
<tr>
<th> </th>
</tr>
</tbody>
</table>


<form method="post" name="suma" action="suma.php">
Ingresa el número 1: <input type="text" name="x1"> <br>
Ingresa el número 2: <input type="text" name="x2"> <br>


<input type="submit" value="comprobar">
</form>

<p>



Mi duda está en esta parte del código php:
<?php
if ($x1. $x2);
echo {"Este es el resultado: $y";}
else
echo {"no intentes timarme.";}
?>
</p>

A ver si me podeis ayudar, un saludo y gracias

</body>
</html>