| Posted by Rik on 01/15/07 08:58 
Jeff wrote:> hey
 >
 > php 5.2.0
 >
 > I have problem with the code below. I haven't entered any values in
 > the secretAnswer input field, so when I submit the form the if test
 > (see below) isn't executed... I thought at least it should print out
 > "no value".. but nothing is echoed to the screen...
 >
 > Any suggestions?
 >
 > <td align="right" style="width:40%;">
 >           <label for="secretAnswer">Hemmelig svar:</label>
 > </td>
 > <td style="width:60%;">
 >           <input type="text" name="secretAnswer" id="secretAnswer" />
 > * </td>
 >
 > $secretAnswer = $_POST["secretAnswer"];
 
 Makes it always set....
 
 either :
 
 if (isset($_POST['secretAnswer'])) {
 echo $secretAnswer;
 } else {
 echo "no value";
 }
 
 or
 
 $secretAnswer = $_POST["secretAnswer"];
 if(!empty($secretAnswer)) {
 echo $secretAnswer;
 } else {
 echo "no value";
 }
 --
 Rik Wasmus
  Navigation: [Reply to this message] |