Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created February 21, 2013 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonycvella/5001158 to your computer and use it in GitHub Desktop.
Save anthonycvella/5001158 to your computer and use it in GitHub Desktop.
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$gameID = generateID();
$createdOn = time();
$homeSchoolID = $_POST['homeSchoolID'];
$awaySchoolID = $_POST['awaySchoolID'];
$numberOfTickets = $_POST['numberOfTickets'];
$db->query("SELECT gameID FROM games WHERE `gameID`=?")->bind(1, $gameID)->execute();
if ($db->getTotalRows()) {
$result = $db->fetch();
}
$db->query("SELECT schoolName FROM schools WHERE `schoolID`=?")->bind(1, $homeSchoolID)->execute();
if ($db->getTotalRows()) {
$result = $db->fetch();
$homeSchool = $result['schoolName'];
}
$db->query("SELECT schoolName FROM schools WHERE `schoolID`=?")->bind(1, $awaySchoolID)->execute();
if ($db->getTotalRows()) {
$result = $db->fetch();
$awaySchool = $result['schoolName'];
}
if (!isset($result)) {
$db->query("INSERT INTO games (`gameID`, `createdOn`, `homeSchoolID`, `awaySchoolID`, `homeSchool`, `awaySchool`, `numberOfTickets`) VALUES (?, ?, ?, ?, ?, ?, ?)")->bind(1, $gameID)->bind(2, $createdOn)->bind(3, $homeSchoolID)->bind(4, $awaySchoolID)->bind(5, $homeSchool)->bind(6, $awaySchool)->bind(7, $numberOfTickets)->execute();
$_SESSION['message'] = 'Game created successfully';
$_SESSION['error_bar'] = 'n_ok';
header("Location: ../addGame.php");
} else {
$_SESSION['message'] = 'Game creation failed';
$_SESSION['error_bar'] = 'n_error';
header("Location: ../addGame.php");
}
} else {
$_SESSION['message'] = 'Game creation failed';
$_SESSION['error_bar'] = 'n_error';
header("Location: ../addGame.php");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment