. */ include "../../functions.php" ; include "../../config.php" ; //New PDO DB connection try { $connection2=new PDO("mysql:host=$databaseServer;dbname=$databaseName;charset=utf8", $databaseUsername, $databasePassword); $connection2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $connection2->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch(PDOException $e) { echo $e->getMessage(); } @session_start() ; //Set timezone from session variable date_default_timezone_set($_SESSION[$guid]["timezone"]); $gibbonYearGroupID=$_GET["gibbonYearGroupID"] ; $URL=$_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/" . getModuleName($_POST["address"]) . "/yearGroup_manage_edit.php&gibbonYearGroupID=" . $gibbonYearGroupID ; if (isActionAccessible($guid, $connection2, "/modules/School Admin/yearGroup_manage_edit.php")==FALSE) { //Fail 0 $URL.="&updateReturn=fail0" ; header("Location: {$URL}"); } else { //Proceed! //Check if school year specified if ($gibbonYearGroupID=="") { //Fail1 $URL.="&updateReturn=fail1" ; header("Location: {$URL}"); } else { try { $data=array("gibbonYearGroupID"=>$gibbonYearGroupID); $sql="SELECT * FROM gibbonYearGroup WHERE gibbonYearGroupID=:gibbonYearGroupID" ; $result=$connection2->prepare($sql); $result->execute($data); } catch(PDOException $e) { //Fail2 $URL.="&deleteReturn=fail2" ; header("Location: {$URL}"); break ; } if ($result->rowCount()!=1) { //Fail 2 $URL.="&updateReturn=fail2" ; header("Location: {$URL}"); } else { //Validate Inputs $name=$_POST["name"] ; $nameShort=$_POST["nameShort"] ; $sequenceNumber=$_POST["sequenceNumber"] ; if ($name=="" OR $nameShort=="" OR $sequenceNumber=="" OR is_numeric($sequenceNumber)==FALSE) { //Fail 3 $URL.="&updateReturn=fail3" ; header("Location: {$URL}"); } else { //Check unique inputs for uniquness try { $data=array("name"=>$name, "nameShort"=>$nameShort, "sequenceNumber"=>$sequenceNumber, "gibbonYearGroupID"=>$gibbonYearGroupID); $sql="SELECT * FROM gibbonYearGroup WHERE (name=:name OR nameShort=:nameShort OR sequenceNumber=:sequenceNumber) AND NOT gibbonYearGroupID=:gibbonYearGroupID" ; $result=$connection2->prepare($sql); $result->execute($data); } catch(PDOException $e) { //Fail 2 $URL.="&updateReturn=fail2" ; header("Location: {$URL}"); break ; } if ($result->rowCount()>0) { //Fail 4 $URL.="&updateReturn=fail4" ; header("Location: {$URL}"); } else { //Write to database try { $data=array("name"=>$name, "nameShort"=>$nameShort, "sequenceNumber"=>$sequenceNumber, "gibbonYearGroupID"=>$gibbonYearGroupID); $sql="UPDATE gibbonYearGroup SET name=:name, nameShort=:nameShort, sequenceNumber=:sequenceNumber WHERE gibbonYearGroupID=:gibbonYearGroupID" ; $result=$connection2->prepare($sql); $result->execute($data); } catch(PDOException $e) { //Fail 2 $URL.="&updateReturn=fail2" ; header("Location: {$URL}"); break ; } //Success 0 $URL.="&updateReturn=success0" ; header("Location: {$URL}"); } } } } } ?>