LOOOL automatizziamo
Codice PHP:
function formFieldChecker( $formData , $config )
{
$errors = 0 ;
foreach( $config as $c=>$v )
{
if( !isset($formData[$c]) )
{
$errors ++
}
else
{
$ctrl = false ;
switch($v)
{
case "email" : $ctrl =filter_var($formData[$c],FILTER_VALçIDATE_EMAIL) ; break ;
/// ETC ETC ETC----
}
if( !$ctrl )
{ $errors ++ ; }
}
}
return $errors ? false : true ;
}
Ovviamente puoi estendere questa funzione per tracciare anche cosa va in errore e non solo "se" unitamente all'estensione ai tipi etc...
Usarla diventa :
Codice PHP:
$myFormConf = array(
"nome" => "string" ,
"cognome" =>"string" ,
"email" => "email"
);
// Puoi fare files di configurazione e usare quella che ti serve ove ti serve :D
$formCheck = formFieldChecker( $_POST, $myFormConf ) ;
luce out! siamo sotto gruppo
EDIT: LOL almost server panic