$referer = $_SERVER['HTTP_REFERER'] . "#" . $_POST['game_id']; // set winner to null $_win = NULL; // if there's a final score if ($_POST['away_final'] != '' && $_POST['home_final'] != '') { // check for a tie if ((int) $_POST['away_final'] == (int) $_POST['home_final']) { $_win = 'TIE'; } elseif ((int) $_POST['away_final'] > (int) $_POST['home_final']) { $_win = $_POST['update_away_team']; } else { $_win = $_POST['update_home_team']; } } // update with new data $gameScore = $db->inputData($_POST['game_id'], $_POST['area'], $_POST['game_date'], $_POST['game_time'], $_POST['update_away_team'], $_POST['update_home_team'], $_POST['facility'], $_win, $_POST['q1_away'], $_POST['q2_away'], $_POST['q3_away'], $_POST['q4_away'], $_POST['ot_away'], $_POST['q1_home'], $_POST['q2_home'], $_POST['q3_home'], $_POST['q4_home'], $_POST['ot_home'], $_POST['sum_head'], $_POST['sum_body'], $_POST['sum_scoring'], $_POST['away_abbr'], $_POST['home_abbr'], $_POST['away_team'], $_POST['home_team'], $_POST['away_final'], $_POST['home_final']); // send back to page that called update header("Location: {$referer}"); } elseif (isset($_POST['update_away'])) { // get the page that sent here $referer = $_SERVER['HTTP_REFERER'] . "#" . $_POST['game_id']; // check if there's a winner // set winner to null $_win = NULL; // if there's a final score if ($_POST['away_final'] != '' && $_POST['home_final'] != '') { // check for a tie if ((int) $_POST['away_final'] == (int) $_POST['home_final']) { $_win = 'TIE'; } elseif ((int) $_POST['away_final'] > (int) $_POST['home_final']) { $_win = $_POST['update_away_team'];