public function register() { if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirmPassword']) && isset($_POST['email'])) { $username = $_POST['username']; $password = $_POST['password']; $cPassword = $_POST['confirmPassword']; $email = $_POST['email']; if ($password != $cPassword) { header('Location: /php_project/application/public/'); } $cleaner = new \Framework\Common(); $newUser['username'] = $cleaner->normalize($username, 'trim|xss|string'); $newUser['password'] = $cleaner->normalize($password, 'trim|xss|string'); $newUser['email'] = $cleaner->normalize($email, 'trim|xss|string'); $userDb = new \Models\User(); $user = $userDb->add($newUser); if (!is_numeric($user)) { header('Location: /php_project/application/public/'); exit; } else { $this->loginAfterRegister($user, $newUser['username']); } } $this->view->appendToLayout('body', 'register'); $this->view->display('layouts.default'); }