// session_start(); include 'TPGP_db.php'; // self post data $iCancel = $_POST['Cancel']; $theSubmitAction = $_POST['Submit']; $theSubjectId = $_POST['theSubjectId']; $Subject = $_POST['Subject']; $theSubjectId = stripslashes($theSubjectId); $Subject = stripslashes($Subject); $iCancel = stripslashes($iCancel); if (iCancel == "Cancel"){ header("Location: TPGP_EditSubjects.php"); } if ($theSubjectId) { if ($theSubmitAction=="Delete Subject") { $sql3 = "DELETE FROM unit INNER JOIN classes ON unit.classID = classes.ClassId WHERE classes.SubjectId=" .$theSubjectId; mysql_query($sql3); $sql99 = "DELETE FROM classes WHERE SubjectID=" .$theSubjectId; mysql_query($sql99); $sql2 = "DELETE FROM subject WHERE SubjectID=" .$theSubjectId; mysql_query($sql2); header("Location: TPGP_EditSubjects.php"); } else { header("Location: TPGP_EditSubjects.php"); } } else { // $PHP_SELF as the form action will cause the script to post to itself $SubjectID = $_GET['ID']; $sql3="SELECT SubjectID, Subject FROM subject WHERE SubjectID =" .$SubjectID; $result3 = mysql_query($sql3); $nrows = mysql_num_rows($result3); $row = mysql_fetch_array($result3); echo '