nome = PostHandler::get("nome"); $obj->cognome = PostHandler::get("cognome"); // ANTICIPATI PER NON PERDERLI IN CASO DI ERRORE $email = trim(PostHandler::get("email")); $obj->email = $email; $username = trim(PostHandler::get("username")); $obj->username = $username; if (is_null($email) || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/",$email)){ throw new GUIException("L'email inserita non è in un formato valido ($email)"); } if (GlobalVariables::get("dao")->count("UserModel",array("email",$email)) > 0 ){ throw new GUIException("L'email inserita è già in uso ($email)"); } // Validate Username if (is_null($username) || strcmp($username,"")==0){ throw new GUIException("Inserire un nome utente valido"); } if (GlobalVariables::get("dao")->count("UserModel",array("username"=>$username ) ) > 0 ){ throw new GUIException("Il nome utente '".$username."' è già in uso"); } $pass = trim(PostHandler::get("password")); $passConf = trim(PostHandler::get("password_confirm")); if (is_null($pass) || strcmp($pass,"")==0){ throw new GUIException("Inserire una password"); } if (strcmp($pass,$passConf)!=0){ throw new GUIException("Le password inserite non coincidono"); } $obj->password = sha1($pass); $obj->newsletter = false; $news = PostHandler::get("newsletter"); if (!is_null($news) && strcasecmp("true", $news)){ $obj->newsletter = true; } $user = new UserModel($obj); GlobalVariables::get("dao")->save($user); $saved = true; } }catch(GUIException $ex){ $msg = $ex->getMessage(); $err = true; }catch (Exception $exec){ $msg = LogModel::fromException($exec); GlobalVariables::get("dao")->save($msg); } if ($saved){ ?> x
La tua registrazione è quasi completa!
A breve riceverai un'email all'indirizzo
email;?>
per completare la registrazione