function inscription() { $erreur_array = array('name' => -1, 'description' => -1, 'contenu' => -1, 'from' => -1, 'to' => -1); $erreur = false; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $array_user = $this->postLogin($erreur, $erreur_array); $nb = $this->userExist(array('email' => $array_user['user']['email'])); if (!$erreur && !$nb) { $array_user['user']['is_verified'] = uniqid(); $userDao = new UserDao(new User($array_user['user'])); $userDao->create(); //die(var_dump($array_services)); $iduser = $userDao->getLastID(); $array_user['adresse']['id_user'] = $iduser; $adresseDao = new AdresseDao(new Adresse($array_user['adresse'])); $adresseDao->create(); $mail = new Mail(); $result = $mail->sendMailActivation('*****@*****.**', $array_user['user']['email'], $array_user['user']['prenom'], $array_user['user']['is_verified']); if ($result['send']) { $this->set(array('success' => '1')); $this->render('inscription'); } } elseif ($nb) { $this->set(array('success' => '2')); $this->render('inscription'); } elseif ($erreur) { $this->render('inscription'); } } $this->set(array('success' => '0')); $this->render('inscription'); }
<?php $errors = array(); $userObj = new User(); if (array_key_exists('signin', $_POST)) { $data = array('email' => $_POST['user']['email'], 'user_password' => $_POST['user']['user_password']); UserMapper::map($userObj, $data); $errors = Validator::validate($userObj); if (empty($errors)) { $dao = new UserDao(); $_SESSION['user_id'] = $dao->create($userObj)->getId(); Utils::redirect(dashboard); } }
<?php $errors = array(); $user_obj = new User(); if (array_key_exists('add', $_POST)) { $data = array('first_name' => $_POST['user']['first_name'], 'user_password' => $_POST['user']['user_password']); UserMapper::map($user_obj, $data); $errors = UserValidator::validate($user_obj); if (empty($errors)) { $dao = new UserDao(); $dao->create($user_obj); Flash::addFlash('1 user is added to db successfully :)'); } }