$loadPage = "templates/views/404.php"; } //Secure Page Checker if (!isset($_SESSION['username']) && $_GET['page'] === "newProduct") { $loadPage = "templates/views/login.php"; $msg = "In order to use this page, you must first login."; } else { unset($msg); } //Object Instantiation $acct = new Account(); $userMapper = new UserMapper(); $gameMapper = new GameMapper(); //Form submission checker logic if (count($_POST) > 0) { $form = new Form(); try { //If the login form is submitted, log in to the user's account if ($_POST['form'] === 'login') { $acct->login(); } else { if ($_POST['form'] === 'register') { //Form Validation if ($form->validateAddUser()) { //If validation passes, add the user to the database. $user = new GameMania\Model\User(0, $_POST['username'], $_POST['email'], hash("sha256", $_POST['password'])); //If the user is successfully registered, tell them. if ($userMapper->addUser($user)) { $msg = "Successfully registered the user!"; } }