public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $tournament = new Tournament($_POST); if ($tournament->getErrorCount() == 0) { HomeView::show(); } else { TournamentCreateView::show($tournament); } } else { // Initial link TournamentCreateView::show(null); } }
public static function run() { $tournament = null; if ($_SERVER["REQUEST_METHOD"] == "POST") { $tournament = new Tournament($_POST); if (is_null($tournament) || $tournament->getErrorCount() != 0) { TournamentCreateView::show($tournament); } else { $tournament = TournamentsDB::addTournament($tournament); } HomeView::show(); header('Location: /' . $_SESSION['base']); } else { // Initial link TournamentCreateView::show(null); } }
public static function run() { $tournament = null; $authenticatedUser = array_key_exists('authenticatedUser', $_SESSION) ? $_SESSION['authenticatedUser'] : null; if ($_SERVER["REQUEST_METHOD"] == "POST") { $tournament = new Tournament($_POST); $tournament->setCreatorID($authenticatedUser->getUserID()); if (is_null($tournament) || $tournament->getErrorCount() != 0) { TournamentCreateView::show($tournament); } else { $tournament = TournamentsDB::addTournament($tournament); } HomeView::show(); header('Location: /' . $_SESSION['base']); } else { // Initial link TournamentCreateView::show(null); } }
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Basic tests for TournamentCreateView</title> </head> <body> <h1>Tournament Create View tests</h1> <?php include_once "../views/TournamentCreateView.class.php"; ?> <h2>It should call show without crashing</h2> <?php TournamentCreateView::show(null); ?> </body> </html>