Location: PHPKode > projects > @1 File Store > libs/forms.php
<?
class UserForms
{
 function UserForms(&$fields)
 {
  foreach($fields AS $key=>$value)
  {
   $fields[$key]["iserror"]=false;
   if(!isset($fields[$key]["value"]))
   {
    $fields[$key]["value"]="";
   }
  }
 }
 
 function sql($fields)
 {
  $SQL="";
  foreach($fields AS $key=>$value)
  {
   if(isset($value["sql"]) && $value["sql"]=="ignore")
   {
    continue;
   }else
    {
     if($SQL!="")
     {
      $SQL.=", ";
     }
     $SQL.="`".$key."`='".AddSlashes(trim($value["value"]))."'";
    }
  }
  return $SQL;
 }
 
 function load(&$fields, $data)
 {
  foreach($fields AS $key=>$value)
  {
   if(isset($data[$key]))
   {
    $fields[$key]["value"]=str_replace("\"", "&quot;", StripSlashes($data[$key]));
   }else
    {
     $fields[$key]["value"]="";
    }
  }
 }

 function check(&$fields)
 {
  $result=0;
  foreach($fields AS $key=>$value)
  {
   if(!$this->checkitem($value))
   {
    $result++;
    $fields[$key]["iserror"]=true;
   }
  }
  return $result;
 }
 
 function checkitem($value)
 {
  if(isset($value["empty"]) && strtolower($value["empty"])=="yes")
  {
  }else
   {
    if(strlen(trim($value["value"]))<=0)
    {
     return false;
    }
   }
  return true;
 }
}
?>
Return current item: @1 File Store