title: Validate fields with isset
body: <p>I try to create a basic calculator, and that works perfectly but i need validate the fields. I' trying with <code>if()</code> but php ignores this. If  fields is empty  not showing the menssage 'Complete all fields' and execute the <code>function operadora();</code> resulting 0. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>Sorry for my bad english :(</p>
  
  <p>This is the form:</p>
  
  <pre><code>&lt;form action="calcular.php" method="post"&gt;
  &lt;input name="valor1" type="number"&gt;
    &lt;select name="operacion" id=""&gt;
      &lt;option value="+"&gt;+&lt;/option&gt;
      &lt;option value="-"&gt;-&lt;/option&gt;
      &lt;option value="*"&gt;*&lt;/option&gt;
      &lt;option value="/"&gt;/&lt;/option&gt;
     &lt;/select&gt;
  &lt;input name="valor2" type="number"&gt;
  &lt;input type="submit" name="enviar" value="enviar"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And this is the php code:</p>
  
  <pre><code>&lt;?php
  
  if(isset($_POST['enviar'])){
    if(!isset($_POST['valor1']) ||
    !isset($_POST['valor2'])){
      echo 'complete all fields';
    }
    else{
      $valor1 = $_POST['valor1'];
      $valor2 = $_POST['valor2'];
      $operacion = $_POST['operacion'];
      operadora($operacion,$valor1,$valor2);
    }
  }
  
  function operadora($operador, $valor1, $valor2){
  if(!strcmp($operador,"+")){
       $resultado = $valor1+$valor2;
       echo $resultado;
     }
  if(!strcmp($operador,"-")){
       $resultado = $valor1-$valor2;
       echo $resultado;
     }
  if(!strcmp($operador,"*")){
       $resultado = $valor1*$valor2;
       echo $resultado;
     }
  if(!strcmp($operador,"/")){
       $resultado = $valor1/$valor2;
       echo $resultado;
     }
  };
  
   ?&gt;
  </code></pre>