Hiding text?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

How can I hide error message when user enters to POST action form for first 
time? I have a form for collecting and saving user data. In the code below 
you can see that  there are text messages for user info stored in $teksti 
variables. At the end the $teksti is passed to function that displays the 
message. Problem is that when user enters the page for firs time the 
variables are empty and therefore basically the decisions made with variable 
values result to error message at the first time.

Thanks for your advice
-Will

Here's code:

if ($ryhma != 'Valitse:' && $ryhma != ''){
  if ($ikaluokka != ''){
 $sql="SELECT ikaluokka FROM x_ikaluokat WHERE ryhma = '$ryhma'";
 $result=mysql_query($sql);
 $num = mysql_num_rows($result);
 $cur = 1;
 if ($num == '0'){
        $check = "ok";
        }
 while ($num >= $cur) {
 $row = mysql_fetch_array($result);
 $il = $row["ikaluokka"];
 if ($il == $ikaluokka){
 $teksti = "Virhe! Samanniminen ikäluokka on jo tässä ryhmässä.";
 $check = "bad";
 } else {
 $check = "ok";
 }
 $cur++;
 }
         if ($check == "ok"){
   $sql_lauseke = "INSERT INTO x_ikaluokat (ryhma, ikaluokka)
   VALUES ('$ryhma','$ikaluokka')";
   if (!$kysely = mysql_query($sql_lauseke,$yhteys)){
          $teksti = "Virhe: " . mysql_error();
   unset($ryhma);
   unset($ikaluokka);
   } else {
          $teksti = "Tallennus onnistui.";
   unset($ryhma);
   unset($ikaluokka);
   }
  }
  } else { $teksti = "Virhe! Ikäluokka puuttuu. Tarkista tiedot."; }
} else { $teksti = "Virhe! Ryhmä puuttuu. Tarkista tiedot."; }


UserMessage ($teksti); 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux