if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_pool", $defined['error'], $db_msg_err, NULL, NULL);
         // attempt to update if record exists
         if (eregi("duplicate", $db->dbCatchError()) || !empty($id)) {
             if (($value = $db->dbQuery($val->ValidateSQL($update, $dbconn), $dbconn)) === -1) {
                 $error = $err->GenerateErrorLink("help/help.html", "#config_pool", $defined['error'], $errors['db_edit_err'], NULL, NULL);
             } else {
                 $error = $err->GenerateErrorLink("help/help.html", "#config_pool", $defined['good'], $errors['db_edit'], NULL, NULL);
             }
         }
     } else {
         $error = $err->GenerateErrorLink("help/help.html", "#config_pool", $defined['good'], $db_msg_good, NULL, NULL);
     }
 } else {
     // find validation errors
     $e = $err->GenerateErrorImg($defined['error'], "help/help.html#config_pool", '800', '800');
     $list .= "<ol>";
     if ($val->ValidateString($pool_name) === -1) {
         $list .= "<li>Pool field is invalid</li>";
         $pool_name_err = $e;
     }
     if ($val->ValidateDomain($dns_server_1) === -1) {
         $list .= "<li>DNS Server 1 field is invalid</li>";
         $dns_server_1_err = $e;
     }
     if ($val->ValidateDomain($dns_server_2) === -1) {
         $list .= "<li>DNS Server 2 field is invalid</li>";
         $dns_server_2_err = $e;
     }
     if ($val->ValidateString($allow_deny) === -1) {
         $list .= "<li>Allow / Deny selection is invalid</li>";
     $error = $err->GenerateErrorLink("help/help.html", "#import_host", $defined['error'], "An error occured when attempting to lookup the duplicate record in which '" . $tmp[$x]['hostname'] . "' conflicts with.", NULL, NULL);
 } else {
     $found = $db->dbArrayResultsAssoc($value);
 }
 // populate our subnets list for our imported record
 $sub = "SELECT `subnet-name` FROM `conf_subnets` ORDER BY `subnet-name` ASC";
 if (($return = $db->dbQuery($val->ValidateSQL($sub, $dbconn), $dbconn)) !== -1) {
     $subs = $db->dbArrayResultsAssoc($return);
 }
 if (count($subs) === 0) {
     $subnet = "No subnets defined";
 } else {
     $subnet = $misc->GenDropMenuWSelectedSubnets($subs, $tmp[$x]['subnet'], 'subnet_tmp');
     // quick check to ensure subnet from import matches existing subnet group
     if (!in_array($tmp[$x]['subnet'], $subs) && !empty($tmp[$x]['subnet'])) {
         $subnet_err[$x] = $err->GenerateErrorImg($defined['error'], "help/help.html#import_host", '800', '800');
         $list .= "<li>Subnet field from import does match current list of existing subnet groups</li>";
     }
 }
 // populate our pxe group list
 $px = "SELECT `pxe-group-name` FROM `conf_pxe_groups` ORDER BY `pxe-group-name` ASC";
 if (($return = $db->dbQuery($val->ValidateSQL($px, $dbconn), $dbconn)) !== -1) {
     $pxeg = $db->dbArrayResultsAssoc($return);
 }
 if (count($pxeg) === 0) {
     $pxe_group = "No PXE Groups defined";
 } else {
     $pxe_group = $misc->GenDropMenuWSelectedPXE($pxeg, $tmp[$x]['pxe_group'], 'pxe_group_tmp');
     // quick check to ensure pxe group form import matches existin pxe group
     if (!in_array($tmp[$x]['pxe_group'], $pxeg) && !empty($tmp[$x]['pxe_group'])) {
         $pxe_group_err[$x] = $err->GenerateErrorImg($defined['error'], "help/help.html#import_host", '800', '800');
 // Free db handle and close connection(s)
 $db->dbFreeData($dbconn);
 $db->dbCloseConn($dbconn);
 // check results of import and application login
 $dbconn = $db->dbConnect($_POST['mysql_server_address'], $_POST['mysql_server_username'], $_POST['mysql_server_password'], 'phpDHCPAdmin');
 if ($dbconn === -1) {
     $error = $err->GenerateErrorLink("../help/help.html", "#app_setup", '../templates/images/error.jpg', "Error connecting to the database with the newly entered username and password combination for the database 'phpDHCPAdmin'", NULL, NULL);
 } else {
     // verify tables exist
     $query = "SHOW TABLES IN `phpDHCPAdmin`";
     if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
         $error = $err->GenerateErrorLink("../help/help.html", "#create_admin_user", '../templates/images/error.jpg', "There was an error when flushing the priveleges table", NULL, NULL);
     } else {
         $array = $db->dbArrayResults($value);
         foreach ($array as $key => $value) {
             $e = $err->GenerateErrorImg('../templates/images/error.jpg', "../help/help.html#app_setup", '800', '800');
             $list .= "<ol>";
             if (!in_array($value['Tables_in_phpDHCPAdmin'], $TABLES)) {
                 $list .= "<li>Missing table information for '" . $value['Tables_in_phpDHCPAdmin'] . "'</li>";
                 $flag = -1;
             }
         }
         $list .= "</ol>";
         if ($flag !== -1) {
             $error = $err->GenerateErrorLink("../help/help.html", "#app_setup", '../templates/images/good.jpg', "Permissions have been set on the database 'phpDHCPAdmin' for the user '" . $_POST['mysql_server_username'] . "' and our table structure is intact.", NULL, NULL);
         } else {
             $error = $err->GenerateErrorLink("../help/help.html", "#app_setup", '../templates/images/error.jpg', "An error occured when verifying database table schema" . $list, NULL, NULL);
         }
     }
 }
 // attempt to write our config file out
                         $remote_id = $data[0]['remote-id'];
                         $ddns_text = $data[0]['ddns-text'];
                         $ddns_fwd_name = $data[0]['ddns-fwd-name'];
                         $ddns_client_fqdn = $data[0]['ddns-client-fqdn'];
                         $ddns_rev_name = $data[0]['ddns-rev-name'];
                         $error = $err->GenerateErrorLink("help/help.html", "#lease_search", $defined['good'], "Your search for '" . $val->ValidateXSS($search) . "' returned '" . $db->dbNumRows($value) . "' results. The form has been populated for you to edit record #" . $id, NULL, NULL);
                     } else {
                         $lease_list = $misc->GenJumpMenuBoxLEASES($data, 'lease_list', $_GET['skin']);
                         $error = $err->GenerateErrorLink("help/help.html", "#lease_search", $defined['good'], "Your search for '" . $val->ValidateXSS($search) . "' returned '" . $db->dbNumRows($value) . "' results. Please select the host you wish to edit from the select box below", NULL, NULL);
                     }
                 } else {
                     $error = $err->GenerateErrorLink("help/help.html", "#lease_search", $defined['error'], $errors['sql_empty'], NULL, NULL);
                 }
             }
         } else {
             $search_err = $err->GenerateErrorImg($defined['error'], "help/help.html#lease_search", '800', '800');
             $list = "<ol><li>Search string is invalid. Allowed formats:<br>MAC Address: xx:xx:xx:xx:xx<br>IPv4 Address: xxx.xxx.xxx.xxx<br>Hostname: [0-9a-z]</li></ol>";
             $error = $err->GenerateErrorLink("help/help.html", "#lease_search", $defined['error'], $errors['val_host'] . $list, NULL, NULL);
         }
     }
 } else {
     // check each post element
     if (!empty($hardware) && !empty($ip) && !empty($start) && !empty($end)) {
         // begin validation of configuration options
         if ($val->ValidateMACFormats($hardware) !== -1 && $val->ValidateIPv4($ip) !== -1 && ($val->ValidateParagraph($start) !== -1 || $val->ValidateParagraph($end) !== -1)) {
             // since no errors for the mac address were recieved assign the *possibly fixed value
             $mac_address = $val->ValidateMACFormats($mac_address);
             // define our sql statements (if group is admin, discard that field)
             if ($group === "admin") {
                 $insert = "INSERT INTO `conf_leases` ( `ip`, `start`, `end`, `cltt`, `current-state`, `next-state`, `hardware`, `hostname`, `abandoned`, `circut-id`, `remote-id`, `ddns-text`, `ddns-fwd-name`, `ddns-client-fqdn`, `ddns-rev-name` ) VALUES ( \"" . $ip . "\", \"" . $start . "\", \"" . $end . "\", \"" . $cltt . "\", \"" . $state . "\", \"" . $next_state . "\", \"" . $hardware . "\", \"" . $hostname . "\", \"" . $abandoned . "\", \"" . $circut_id . "\", \"" . $remote_id . "\", \"" . $ddns_text . "\", \"" . $ddns_fwd_name . "\", \"" . $ddns_client_fqdn . "\", \"" . $ddns_rev_name . "\" )";
                 $update = "UPDATE `conf_leases` SET `ip` = \"" . $ip . "\", `start` = \"" . $start . "\", `end` = \"" . $end . "\", `cltt` = \"" . $cltt . "\", `current-state` = \"" . $state . "\", `next-state` = \"" . $next_state . "\", `hardware` = \"" . $hardware . "\", `hostname` = \"" . $hostname . "\", `abandoned` = \"" . $abandoned . "\", `circut-id` = \"" . $circut_id . "\", `remote-id` = \"" . $remote_id . "\", `ddns-text` = \"" . $ddns_text . "\", `ddns-fwd-name` = \"" . $ddns_fwd_name . "\", `ddns-client-fqdn` = \"" . $ddns_client_fqdn . "\", `ddns-rev-name` = \"" . $ddns_rev_name . "\" WHERE `id` = \"" . $id . "\" LIMIT 1";
     if (($sql_res = $db->dbQuery($val->ValidateSQL($sql, $dbconn), $dbconn)) === -1) {
         if (eregi("duplicate", $db->dbCatchError())) {
             $sql = $update;
             $sql = $val->ValidateSQL($sql, $dbconn);
             if (($sql_res = $db->dbQuery($sql, $dbconn)) === -1) {
                 $message = $err->GenerateErrorLink("help/help.php", "#sql_error", $defined['error'], $errors['db_edit_err'], '600', '600');
             }
         } else {
             $message = $err->GenerateErrorLink("help/help.php", "#db_insert", $defined['good'], $errors['db_edit'], '600', '600');
         }
     } else {
         $message = $err->GenerateErrorLink("help/help.php", "#db_insert", $defined['good'], $errors['db_insert'], '600', '600');
     }
 } else {
     // create a reusable error link
     $erlink = $err->GenerateErrorImg($defined['error'], "help/help.html#val_par", "#val_par", '600', '600');
     $list = "<ol>";
     // determine our validate errors
     if ($val->ValidateParagraph($group_name) === -1) {
         $list .= "<li>Name field is invalid</li>";
         $group_name_err = $erlink;
     }
     if ($val->ValidatePhone($group_contact) === -1) {
         $list .= "<li>Contact field is invalid, phone number expected xxx-xxx-xxxx</li>";
         $group_contact_err = $erlink;
     }
     if ($val->ValidateParagraph($group_description) === -1) {
         $list .= "<li>Description field is invalid</li>";
         $group_description_err = $erlink;
     }
     if ($val->ValidateParagraph($group_manager) === -1) {