public function create() { $data = array(); $clientCollection = new ClientsCollection(); $insertInfo = array('username' => '', 'password' => '', 'email' => ''); $errors = array(); if (isset($_POST['createUser'])) { $insertInfo = array('username' => isset($_POST['username']) ? $_POST['username'] : '', 'password' => isset($_POST['password']) ? $_POST['password'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : ''); $errors = $this->validateUserInput($insertInfo); if (empty($errors)) { $clientEntity = new ClientsEntity(); $obj = $clientEntity->init($insertInfo); $clientCollection->save($obj); $_SESSION['flashMessage'] = 'You have 1 new user'; header('Location: index.php?c=client&m=index'); } } $data['errors'] = $errors; $data['insertInfo'] = $insertInfo; $this->loadView('clients/create', $data); }
header('Location: clients.php'); } $clientCollection = new ClientsCollection(); $client = $clientCollection->getOne($_GET['id']); if (is_null($client)) { header('Location: clients.php'); } $insertInfo = array('username' => $client->getUsername(), 'password' => '', 'email' => $client->getEmail()); $errors = array(); if (isset($_POST['editUser'])) { $insertInfo = array('username' => isset($_POST['username']) ? $_POST['username'] : '', 'password' => isset($_POST['password']) ? $_POST['password'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : ''); $errors = validateUserInput($insertInfo); if (empty($errors)) { $clientEntity = new ClientsEntity(); $clientEntity->setId($_GET['id']); $obj = $clientEntity->init($insertInfo); $clientCollection->save($obj); $_SESSION['flashMessage'] = 'You have 1 affected row'; header('Location: clients.php'); } } ?> <?php require_once 'common/sidebar.php'; ?> <!-- start: Content --> <div id="content" class="span10"> <ul class="breadcrumb">