if (!$added) { echoResponse('no', $added->error); } else { //echoResponse('yes','Field Added!'); $settingFirstSetup = "UPDATE board SET firstSetup='1' WHERE boardName='" . getBoardName() . "'"; $settedFirstSetup = $connection->query($settingFirstSetup); if (!$settedFirstSetup) { echoResponse('no', $settedFirstSetup->error); } else { //echoResponse('yes','First Setup Done!'); $remoteGroupName = sanitizeInput($_POST['remoteGroupName']); if (addGroupName($remoteGroupName)) { $addingField = 'ALTER TABLE users ADD groupName varchar(20)'; $added = $connection->query($addingField); //groupName added to users table $data = getAdminData('admin'); $queryModifyAdmin = "UPDATE users SET groupName='{$remoteGroupName}' WHERE username='******'"; //binding first admin to remote group $executeModifyAdmin = $connection->query($queryModifyAdmin); $seedingFirstGroup = "INSERT INTO " . $remoteGroupName . " (`username`, `name`, `surname`) VALUES ('" . $data[0] . "','" . $data[1] . "','" . $data[2] . "')"; //setting first admin in the remoteGroup $seeded = $connection->query($seedingFirstGroup); $createTableList = "CREATE TABLE tablelist\n (tabName varchar(20),\n tabType varchar(20),\n INDEX(tabName(20)),\n PRIMARY KEY(tabName)) DEFAULT CHARSET=utf8 Engine InnoDB"; $executeCreateTableList = $connection->query($createTableList); seedTableList($remoteGroupName, 'remoteGroup'); seedTableList('board', 'services'); seedTableList('users', 'services'); $connection->close(); echoResponse('yes', "Table {$remoteGroupName} and tableList created and other tables modified successfully!"); } else { echoResponse('no', 'error creating table');
function getAdminData($c) { $adminName = $c->input("Account name: "); $adminPass = $c->input("Password: "******"Is the information correct? (y/n) ")) { return [$adminName, $adminPass]; } else { $c->put(); return getAdminData($c); } }