public function adduserAction() { $idUser = $_SESSION["idUser"]; $lastName = $_SESSION['lastName']; $firstName = $_SESSION['firstName']; $picture = $_SESSION['photo']; $role = $_SESSION['role']; $email = $_SESSION['email']; //On teste si l'utilisateur n'existe pas dans la BDD avant de l'inserer $testObj = new memberModel(); $testObj->getOneByIdmember($idUser); // Insertion d'un utilisateur seulement // A commenter pour que les admins puissent participer if ($testObj->getIdMember() == 0) { $member = new memberModel($lastName, $firstName, $picture, $idUser, $email); $member->save(); header('Location: /contest'); } else { header('Location: /contest'); } }
public function editAction() { $uid = (int) $_GET['uid']; $mMember = new memberModel(); $mMember->debug = true; if (empty($_POST)) { $member = $mMember->findByPrk($uid); $formset = Form::formSet($member); $formerror = Form::formError($_SESSION['formerror']); unset($_SESSION['formset'], $_SESSION['formerror']); include $this->template(); } else { $data = $_POST; $error = $mMember->validate($data, 'all_one'); if (!$error) { $mMember->save($_POST); $this->redirect($_SERVER['HTTP_REFERER'], 1, '编辑成功'); } else { $_SESSION['formerror'] = $error; $this->redirect($_SERVER['HTTP_REFERER']); } } }