Created
February 21, 2013 01:19
-
-
Save anthonycvella/5001158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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