Location: PHPKode > projects > AJAX MySQL Admin > ajaxmysqladmin/www/api/settings.php
<?php
    require_once ('inc/constants.inc');
    require_once ('inc/generic_start.inc');
    $shown = false;

    $action = $_GET['action'];
    if ($action == 'set') {
        $dbhost = $_GET ['dbhost'];
        $dbport = $_GET ['dbport'];
        $dbuser = $_GET ['dbuser'];
        $dbpass = $_GET ['dbpass'];
        $query = "SELECT username FROM connections WHERE username='" . $username . "' LIMIT 0,1";
        $result = mysql_query ($query, $app_conn);
        if ($result !== FALSE && mysql_num_rows ($result) > 0) {
            $query = "UPDATE connections SET dbhost='" . $dbhost . "', dbport='" . $dbport . "', dbuser='" . $dbuser . "', dbpass='" . $dbpass . "' WHERE username='" . $username  . "'";
        } else {
            $query = "INSERT INTO connections (username, dbhost, dbport, dbuser, dbpass) VALUES ('" . $username . "', '" . $dbhost . "', '" . $dbport . "', '" . $dbuser . "', '" . $dbpass . "')";
        }
        mysql_query ($query, $app_conn);
        ?>
        {response:1}
        <?php
    } else {
        if ($dbhost != null) {
            ?>
            {
                host: '<?php echo $dbhost; ?>',
                port: '<?php echo $dbport; ?>',
                username: '<?php echo $dbuser; ?>',
                password: '<?php echo $dbpass; ?>',
                name: '<?php echo $dbname; ?>'
            }
            <?php
        } else {
            ?>
            {response:0}
            <?php
        }
    }

    require_once ('inc/generic_finish.inc');
?>
Return current item: AJAX MySQL Admin