$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) {
                die($e->getMessage());
            }
            $displayErrors = "none";
        } else {
            $errorDisplay = "";
            $displayErrors = "block";
            foreach ($validation->errors() as $error) {
                $errorDisplay = $errorDisplay . $error . "<br>";
            }
        }
    }
}