Restart, please"); } else { //Connect to the database and select used database include('user.php'); $connection = mysql_connect("$host","$user","$password") or die(mysql_error()); mysql_select_db("$txt_db_name",$connection) or die(mysql_error()); $seasonid = $_SESSION['season_id']; $seasonname = $_SESSION['season_name']; //Mahdolliset lomakkeiden nappimuuttujat $add_squad_submit = $_POST['add_squad_submit']; $add_goalscorer_submit = $_POST['add_goalscorer_submit']; $add_yellowcard_submit = $_POST['add_yellowcard_submit']; $add_redcard_submit = $_POST['add_redcard_submit']; $add_substitutes_submit = mysql_real_escape_string($_POST['add_substitutes_submit']); $add_substitutions_submit = mysql_real_escape_string($_POST['add_substitutions_submit']); //Osoiterivilt� tulevat muuttujat $action = $_REQUEST['action']; $HTTP_REFERER = $_SERVER['HTTP_REFERER']; //Pelaajan lis�ys avauskokoonpanoon if($add_squad_submit) { $add_to_squad = $_POST['add_to_squad']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; $manager = $_POST['manager'] * 1; $table = $manager ? "tplss_appearancesmngr" : "tplss_appearances"; // //K�yd��n l�pi koko dropdown menun sis�lt� eli katsotaan mitk� pelaajat on valittu // foreach($add_to_squad as $playerid) { //Pelaaja ei ole viel� squadissa, voidaan siis lis�t� pelaaja tietokantaan mysql_query("INSERT INTO {$table} SET AppearancePlayerID = '$playerid', AppearanceMatchID = '$matchid', AppearanceSeasonID = '$season_id'", $connection) or die(mysql_error()); } header("Location: $HTTP_REFERER"); } //Pelaajan lis�ys maalintekij�ihin elseif($add_goalscorer_submit) { $playerid = $_POST['add_to_goalscorers']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; $minute = trim($_POST['minute']); $owngoal = $_POST['owngoal']; $penalty = $_POST['penalty']; $ownscorer = trim($_POST['ownscorer']); //Tarkistetaan my�s, onkko penalty ja own goal molemmat ruksattu if(isset($owngoal) && isset($penalty)) { header("Location: $HTTP_REFERER"); exit(); } // //Pelaaja ei ole viel� squadissa, voidaan siis lis�t� pelaaja tietokantaan //Tarkastetaan samalla, onko penalty ja own goal ruksattu // if(isset($penalty)) { mysql_query("INSERT INTO tplss_goals SET GoalPlayerID = '$playerid', GoalMatchID = '$matchid', GoalSeasonID = '$season_id', GoalPenalty = '1', GoalMinute = '$minute', GoalOwnScorer = ''", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif(isset($owngoal)) { mysql_query("INSERT INTO tplss_goals SET GoalPlayerID = '$playerid', GoalMatchID = '$matchid', GoalSeasonID = '$season_id', GoalOwn = '1', GoalMinute = '$minute', GoalOwnScorer = '$ownscorer'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } else { mysql_query("INSERT INTO tplss_goals SET GoalPlayerID = '$playerid', GoalMatchID = '$matchid', GoalSeasonID = '$season_id', GoalMinute = '$minute', GoalOwnScorer = ''", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } } //Pelaajan lis�ys keltaisiin kortteihin elseif($add_yellowcard_submit) { $playerid = $_POST['add_to_yellowcards']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; $minute = $_POST['minute']; //Pelaaja ei ole viel� squadissa, voidaan siis lis�t� pelaaja tietokantaan mysql_query("INSERT INTO tplss_yellowcards SET YellowCardPlayerID = '$playerid', YellowCardMatchID = '$matchid', YellowCardSeasonID = '$season_id', YellowCardMinute = '$minute'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } //Pelaajan lis�ys punaisiin kortteihin elseif($add_redcard_submit) { $playerid = $_POST['add_to_redcards']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; $minute = $_POST['minute']; //Pelaaja ei ole viel� punaisissa, voidaan siis lis�t� pelaaja tietokantaan mysql_query("INSERT INTO tplss_redcards SET RedCardPlayerID = '$playerid', RedCardMatchID = '$matchid', RedCardSeasonID = '$season_id', RedCardMinute = '$minute'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } //Lis�ys vaihtomiehiin elseif($add_substitutes_submit) { $add_to_substitutes = $_POST['add_to_substitutes']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; // //K�yd��n l�pi dropdownista tulleet valitut pelaajat // foreach($add_to_substitutes as $playerid) { //Pelaaja ei ole viel� squadissa, voidaan siis lis�t� pelaaja tietokantaan mysql_query("INSERT INTO tplss_substitutes SET SubstitutePlayerID = '$playerid', SubstituteMatchID = '$matchid', SubstituteSeasonID = '$season_id'", $connection) or die(mysql_error()); } header("Location: $HTTP_REFERER"); } //Lis�ys vaihtoihin elseif($add_substitutions_submit) { $playeridin = $_POST['add_to_substitutions_in']; $playeridout = $_POST['add_to_substitutions_out']; $matchid = $_POST['matchid']; $season_id = $_POST['season_id']; $minute = $_POST['minute']; if($playeridin == "$playeridout") { echo'In and out player can\'t be the same.
Push back button to get back.'; exit(); } // //Lis�ys vaihtoihin // mysql_query("INSERT INTO tplss_substitutions SET SubstitutionPlayerIDIn = '$playeridin', SubstitutionPlayerIDOut = '$playeridout', SubstitutionMatchID = '$matchid', SubstitutionSeasonID = '$season_id', SubstitutionMinute = '$minute'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } //Poistotoiminnot elseif($action) { //Poisto aloituskokooonpanosta if($action == 'remove_from_squad') { $id = $_GET['id']; $manager = $_GET['manager'] * 1; $table = $manager ? "tplss_appearancesmngr" : "tplss_appearances"; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM {$table} WHERE AppearanceID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif($action == 'remove_from_goalscorers') { $id = $_REQUEST['id']; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM tplss_goals WHERE GoalID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif($action == 'remove_from_yellowcards') { $id = $_REQUEST['id']; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM tplss_yellowcards WHERE YellowCardID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif($action == 'remove_from_redcards') { $id = $_REQUEST['id']; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM tplss_redcards WHERE RedCardID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif($action == 'remove_from_substitutes') { $id = $_REQUEST['id']; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM tplss_substitutes WHERE SubstituteID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } elseif($action == 'remove_from_substitutions') { $id = $_REQUEST['id']; //Poistetaan ja palautetaan edelliselle sivulle mysql_query("DELETE FROM tplss_substitutions WHERE SubstitutionID = '$id'", $connection) or die(mysql_error()); header("Location: $HTTP_REFERER"); } } } mysql_close($connection); ?>