prepare("SELECT id, userrole, username FROM app_users WHERE BINARY username = ?"); $querysel->bind_param("s", $username); $querysel->execute(); $confdatafromdb = $querysel->get_result()->fetch_assoc(); $cruserid = $confdatafromdb['id']; $cruserrole = $confdatafromdb['userrole']; if ($cruserrole == 'superadmin') { // Remove the text conference data from the 'conferences_text' table $querydel = $mysqli->prepare("DELETE FROM conferences_text WHERE text_conf_extension = ?"); $querydel->bind_param("s", $textConfExtension); if ($querydel->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while removing the data !'; } } elseif ($cruserrole == 'admin') { // Get the id of the user who saved this conference data $queryfd = $mysqli->prepare("SELECT id, userid, text_conf_extension FROM conferences_text WHERE text_conf_extension = ?"); $queryfd->bind_param("s", $textConfExtension); $queryfd->execute(); $confdatadb = $queryfd->get_result()->fetch_assoc(); $useridfdb = $confdatadb['userid']; if ($useridfdb == $cruserid) { // Remove the text conference data from the 'conferences_text' table $querydelad = $mysqli->prepare("DELETE FROM conferences_text WHERE userid = ? AND text_conf_extension = ?"); $querydelad->bind_param("is", $cruserid, $textConfExtension); if ($querydelad->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while removing the data !'; } } else { $messagetosend = "You are not allowed to remove this conference data!"; } } elseif ($cruserrole == 'regular_user') { $messagetosend = 'Only Admins and Superadmins can remove conference data!'; } $response = array('result' => $messagetosend); echo json_encode($response); } else { header("Location: ../login.php"); } ?>