Exemplo n.º 1
0
<?php

require_once 'core/init.php';
$pageTitle = 'Update an Opponent';
$user = new User();
if (!$user->isLoggedIn()) {
    Redirect::to('login.php');
}
// Defaults
$style = '';
$displayErrors = "none";
$errorDisplay = "";
$leagueOptions = new League();
if (isset($_GET['opponentId']) && is_numeric($_GET['opponentId'])) {
    $opponent = $leagueOptions->getOpponentById(escape($_GET['opponentId']));
    if (!$opponent) {
        die("Opponent not found");
    } else {
        $results = $opponent;
    }
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validation();
        $validation = $validate->check($_POST, array('OpponentName' => array('name' => 'Opponent', 'min' => 5, 'max' => 50, 'required' => true)));
        if ($validation->passed()) {
            try {
                $leagueOptions->updateOpponent(array('OpponentName' => Input::get('OpponentName')), Input::get('OpponentId'));
                Session::flash('OpponentUpdated', 'Opponent Updated Successfully');
                Redirect::to('opponents.php');
            } catch (Exception $e) {