<?php include_once '../bootstrap.php'; use Models\LoginManager; use Views\LoginView; LoginManager::startSession(); if ($_SERVER['REQUEST_METHOD'] === 'GET') { $loginView = new LoginView(false); $loginView->render(); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = $_POST['username']; $password = $_POST['password']; $loginManager = new LoginManager(); $isLoginSuccess = $loginManager->isValid($username, $password); if ($isLoginSuccess) { header("Location: /auction/homepage"); exit; } else { $loginView = new LoginView(true); $loginView->render(); } }
* Created by PhpStorm. * User: Claz * Date: 05/02/2016 * Time: 11:58 */ include_once '../bootstrap.php'; use Models\LoginManager; use Models\UserManager; use Views\RegisterView; LoginManager::startSession(); //minimum to create the view and render $username = $_REQUEST['username']; $first_name = $_REQUEST['first_name']; $last_name = $_REQUEST['last_name']; $email = $_REQUEST['email']; $email_check = $_REQUEST['email_check']; $role_id = $_REQUEST['role_id']; $description = $_REQUEST['description']; $password = $_REQUEST['password']; $password_check = $_REQUEST['password_check']; $registerManager = new UserManager(); $isRegisterSuccess = $registerManager->registerUser($username, $first_name, $last_name, $email, $email_check, $role_id, $description, $password, $password_check); $loginManager = new LoginManager(); $login = $loginManager->isValid($username, $password); if ($isRegisterSuccess) { header("Location: /auction/homepage"); exit; } else { $registerView = new RegisterView(true); $registerView->render(); }