Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/enclosurepost.php
<?php ob_start();

require_once 'database.php'; 
require_once 'history.php';
require_once 'usercheck.php';

    // connect to the db
    ttdb_connect($connection);
    ttdb_beginTransaction($connection);

    if ($idenclosure == "") {
        
        $newEnclosureId = ttdb_getSequenceValue($connection, 'enclosure');    
        
        // is an insert of an enclosure, add a new register
        
        $sql="insert into enclosure ".
            "(iid, iiddefect, stitle, stext) ".
            "values ($newEnclosureId, $iddefect, '$fTitle', '$fText');";
        $history = "Added enclosure \'".$fTitle."\' by $ddts_username";
        
    }    
    else {
    
        // update the enclosure
        $sql="update enclosure ".
            " set stitle='$fTitle',".
            " stext='$fText' ".
            " where iid=$idenclosure;";    
        $history = "Modified enclosure \'".$fTitle."\' by $ddts_username";
        
    }

    // execute it
    $result = ttdb_execQuery($connection, $sql);
    
    if(!$result) {
        printf("An error occurred working with the database. [$sql]</br>");
        ttdb_rollbackTransaction($connection);
        exit("ERROR");
    }

    tt_historyEntry($connection, $iddefect, $history);

    // go to the VisualizeForm page
    ttdb_commitTransaction($connection);
    ttdb_close($connection);
    
    header("Location: visualize.php?iddefect=$iddefect");
    ob_end_flush();
?>
Return current item: Druid Defect Control