Salve a tutti.
Ho scaricato lo script di "Gestire utenti con php" di html.it.
Nel register.php ho notato questa riga di codice:
La funzione reg_register() contiene questo:codice:$ret = reg_check_data($_POST); $status = ($ret === true) ? reg_register($_POST) : REG_ERRORS;
E la funzione reg_check_data() contiene:codice:function reg_register($data){ //registro l'utente global $_CONFIG; $id = reg_get_unique_id(); mysql_query(" INSERT INTO ".$_CONFIG['table_utenti']." (name, surname, indirizzo, occupazione, username, password, temp, regdate, uid) VALUES ('".$data['name']."','".$data['surname']."','".$data['indirizzo']."', '".$data['occupazione']."','".$data['username']."',MD5('".$data['password']."'), '1', '".time()."','".$id."')"); //Decommentate la riga seguente per testare lo script in locale //echo "<a href=\"http://localhost/Articoli/autenticazione/2/scripts/confirm.php?id=".$id."\">Conferma</a>"; if(mysql_insert_id()){ return reg_send_confirmation_mail($data['mail'], "test@localhost", $id); }else return REG_FAILED; }
Qualcuno puo spiegarmi un attimo a cosa servono?codice:function reg_check_data(&$data){ global $_CONFIG; $errors = array(); foreach($data as $field_name => $value){ $func = $_CONFIG['check_table'][$field_name]; if(!is_null($func)){ $ret = $func($value); if($ret !== true) $errors[] = array($field_name, $ret); } } return count($errors) > 0 ? $errors : true; }
Grazie mille.

Rispondi quotando