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"; } $tourneyName = $_POST["tourneyName"]; $tourneyDate = $_POST["tourneyDate"]; $division = $_POST["division"]; $numPlayers = $_POST["numPlayers"]; $bestOf = $_POST["bestOf"]; $winningTeamName = $_POST["winningTeamName"]; $notes = $_POST["notes"]; // Create a unique ID for the tournament $tourneyUID = uniqid(rand()); 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("INSERT INTO " . $tournamentDataTableName . " ( tournamentUID, tournamentName, tournamentDate, tournamentDivision, numPlayers, bestOf, winningTeamName, winner1, winner2, winner3, winner4, notes ) VALUES ( :tournamentUID, :tournamentName, :tournamentDate, :tournamentDivision, :numPlayers, :bestOf, :winningTeamName, :winner1, :winner2, :winner3, :winner4, :notes )"); $insert->bindValue(":tournamentUID", $tourneyUID); $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->execute(); echo "Successfully uploaded new tournament record"; } catch (PDOException $e) { // failed connection echo "Connection failed: " . $e->getMessage(); } $conn = null; ?>