query("SELECT id, userrole, username, enabled FROM app_users WHERE userrole = 'superadmin' AND BINARY username = '$username' AND enabled = 1"); $queryres = $query1->fetch_array(); $userID = $queryres[0]; $extdatafromdb = []; if ($userID != '') { // Get the data for the current user from the 'external_users' table $querysel = $mysqli->query("SELECT id, userid, exten_for_external, exten_for_ext_pass, conf_access_link FROM external_users WHERE userid = '$userID'"); while ($extUserDataRow = $querysel->fetch_row()) { $extenforexternal = $extUserDataRow[2]; if ($extUserDataRow[3] != '' && $extUserDataRow[3] != null && $extUserDataRow[3] != 'undefined') { $sippassword = "%20%20%20%20%20%20%20"; } else { $sippassword = ''; } $confaccesslink = $extUserDataRow[4]; $extdatafromdb[] = ['exten_for_external' => $extenforexternal, 'exten_for_ext_pass' => $sippassword, 'conf_access_link' => $confaccesslink]; } } echo json_encode($extdatafromdb); } else { header("Location: roundpin-login.php"); } ?>