Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/useroptionspost.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css">
</head>

<body>
<?php include 'header.php'; ?> <?php ob_start();

require_once 'database.php'; 
require_once 'usercheck.php';
require_once 'errors.php';

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

    // first check the user exists in the table
    global $ddts_username;
    $lookforsql="select iid from users where sname = '$ddts_username';";

    $result= ttdb_execQuery($connection, $lookforsql);
    if(!$result){
        tter_errorWithBackButton("An error occurred querying the database. [$lookforsql]</br>");
        ttdb_rollbackTransaction($connection);
        exit;
    }
    
    $fields = ttdb_getArray($result);
    
    if (!is_array($fields)) {
        tter_errorWithBackButton("The user $ddts_username doesn't exist.");
        ttdb_rollbackTransaction($connection);
        exit;
    }
    
    // Check that password has been retyped correctly. 
    if ($fPassword != $fRetypePassword) {
        tter_errorWithBackButton("Passwords are not the same. Please go back and retype them.");
        ttdb_rollbackTransaction($connection);
        exit;
    }
    
    if ($fDefaultProject == "")
        $fDefaultProject = "null";

    if ($fPassword != "") {   // Password has been specified
        $updatesql="update users set ".
            " sEmail = '$fEmail', ".            
            " sContactPhone = '$fContactPhone', ".
            " sContactAddress = '$fContactAddress', ".
            " sPassword = '$fPassword' ".
            " iiddefaultproject = $fDefaultProject ".
            "where sname = '$ddts_username'";
    } else {                  // Password has NOT been specified
        $updatesql="update users set ".
            " sEmail = '$fEmail', ".
            " sContactPhone = '$fContactPhone', ".
            " sContactAddress = '$fContactAddress', ".
            " iiddefaultproject = $fDefaultProject ".
            "where sname = '$ddts_username'";
    }

    // execute it
    $result= ttdb_execQuery($connection, $updatesql);
    if(!$result){
        tter_errorWithBackButton("An error occurred updating the database. [$updatesql]</br>");
        ttdb_rollbackTransaction($connection);
        exit;
    }

    ttdb_commitTransaction($connection);
    ttdb_close($connection);
    
    //header("Location: useroptions.php");
    ob_end_flush();
?> 
<h1>User options updated </h1>
<p>Your information has been correctly updated. </p>
<p><a href="useroptions.php">Go back to the options page</a></p>
</body>
</html>
Return current item: Druid Defect Control