header('Location: create_edit_guideline.php?id=' . $gid);
             exit;
         }
     }
 } else {
     if (isset($_POST['remove'])) {
         foreach ($_POST as $name => $value) {
             // the check ids need to be removed are in an array
             if (substr($name, 0, 13) == 'del_checks_id' && is_array($value)) {
                 $value_prefix = substr($name, 14);
                 $action_on = explode('_', $value_prefix);
                 $action_on_element = $action_on[0];
                 $action_on_id = $action_on[1];
                 if ($action_on_element == 'g') {
                     foreach ($value as $del_check_id) {
                         $subgroupChecksDAO->deleteChecksByTypeAndID('guideline', $action_on_id, substr($del_check_id, strlen($value_prefix) + 1));
                     }
                 }
                 if ($action_on_element == 'gg') {
                     foreach ($value as $del_check_id) {
                         $subgroupChecksDAO->deleteChecksByTypeAndID('group', $action_on_id, substr($del_check_id, strlen($value_prefix) + 1));
                     }
                 }
                 if ($action_on_element == 'gsg') {
                     foreach ($value as $del_check_id) {
                         $subgroupChecksDAO->deleteChecksByTypeAndID('subgroup', $action_on_id, substr($del_check_id, strlen($value_prefix) + 1));
                     }
                 }
             }
         }
     }