// session_start(); include 'TPGP_db.php'; // self post data $iCancel = $_POST['Cancel']; $theSubmitAction = $_POST['Submit']; $theUnitId = $_POST['theUnitId']; $classId = $_POST['theClassId']; $theUnitId = stripslashes($theUnitId); $iCancel = stripslashes($iCancel); if (iCancel == "Cancel"){ header("Location: TPGP_EditUnits.php?ID=" .$classId); } // echo $PHP_SELF // THIS IS WHERE THE SELF POST FORM GOES // Define post fields into simple variables if ($theUnitId) { if ($theSubmitAction=="Delete Unit") { $sql2 = "DELETE FROM unit WHERE unitID=" .$theUnitId; mysql_query($sql2); header("Location: TPGP_EditUnits.php?ID=" .$classId); } else { header("Location: TPGP_EditUnits.php?ID=" .$classId); } } else { // $PHP_SELF as the form action will cause the script to post to itself $UnitIDENT = $_GET['ID']; $sql3="SELECT unit.unitID, unit.classID, classes.ClassName, unit.unit, unit.lesson FROM unit INNER JOIN classes ON unit.classID = classes.ClassId WHERE unit.unitID=" .$UnitIDENT; // BE SURE TO GO BACK AND LOOK FOR ALL THE RELATED UNITS AND DELETE THEM // $result3 = mysql_query($sql3); $nrows = mysql_num_rows($result3); $row = mysql_fetch_array($result3); $list_comp = $row["classID"]; $sql4="SELECT ClassId,ClassName from classes"; $result4 = mysql_query($sql4) or die("error in SQL"); echo '