setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Need to check if values were sent over POST, otherwise set to N/A if (isset($_POST["winningPlayer1"])) { $winningPlayer1 = $_POST["winningPlayer1"]; } else { $winningPlayer1 = "N/A"; } if (isset($_POST["winningPlayer2"])) { $winningPlayer2 = $_POST["winningPlayer2"]; } else { $winningPlayer2 = "N/A"; } if (isset($_POST["winningPlayer3"])) { $winningPlayer3 = $_POST["winningPlayer3"]; } else { $winningPlayer3 = "N/A"; } if (isset($_POST["winningPlayer4"])) { $winningPlayer4 = $_POST["winningPlayer4"]; } else { $winningPlayer4 = "N/A"; } $tourneyID = $_POST["tourneyID"]; $tourneyUID = $_POST["tourneyUID"]; $tourneyName = $_POST["tourneyName"]; $tourneyDate = $_POST["tourneyDate"]; $division = $_POST["division"]; $numPlayers = $_POST["numPlayers"]; $bestOf = $_POST["bestOf"]; $winningTeamName = $_POST["winningTeamName"]; $notes = $_POST["notes"]; echo "

$tourneyName

"; echo "

$tourneyDate

"; echo "

$tourneyUID

"; echo "

$division

"; echo "

$numPlayers

"; echo "

$bestOf

"; echo "

$winningTeamName

"; echo "

$winningPlayer1

"; echo "

$winningPlayer2

"; echo "

$winningPlayer3

"; echo "

$winningPlayer4

"; echo "

$notes

"; $insert = $conn->prepare("UPDATE " . $tournamentDataTableName . " SET tournamentName = :tournamentName, tournamentDate = :tournamentDate, tournamentDivision = :tournamentDivision, numPlayers = :numPlayers, bestOf = :bestOf, winningTeamName = :winningTeamName, winner1 = :winner1, winner2 = :winner2, winner3 = :winner3, winner4 = :winner4, notes = :notes WHERE tournamentID = :tournamentID "); $insert->bindValue(":tournamentName", $tourneyName); $insert->bindValue(":tournamentDate", $tourneyDate); $insert->bindValue(":tournamentDivision", $division); $insert->bindValue(":numPlayers", $numPlayers); $insert->bindValue(":bestOf", $bestOf); $insert->bindValue(":winningTeamName", $winningTeamName); $insert->bindValue(":winner1", $winningPlayer1); $insert->bindValue(":winner2", $winningPlayer2); $insert->bindValue(":winner3", $winningPlayer3); $insert->bindValue(":winner4", $winningPlayer4); $insert->bindValue(":notes", $notes); $insert->bindValue(":tournamentID", $tourneyID); $insert->execute(); echo "Successfully edited tournament record"; // Function from StackOverflow used to get the base URL, to which we append // the redirect (where the user came from) function url(){ return sprintf( "%s://%s/tournament", isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', $_SERVER['SERVER_NAME'] ); } $address = url(); echo "

Redirecting to $address/$tourneyUID...

"; echo ""; } catch (PDOException $e) { // failed connection echo "Connection failed: " . $e->getMessage(); } $conn = null; ?>