prepare($sql_check_roles); $stmt_check_roles->bind_param("s", $username); $stmt_check_roles->execute(); $result_check_roles = $stmt_check_roles->get_result(); while ($row = $result_check_roles->fetch_assoc()) { if ($row['role'] == 'admin') { $is_admin = true; } elseif ($row['role'] == 'mod') { $is_mod = true; } } $stmt_check_roles->close(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['group_message'])) { $group_message = $_POST['group_message']; $stmt = $conn->prepare("INSERT INTO group_messages (user_id, message) VALUES (?, ?)"); $stmt->bind_param("is", $user_id, $group_message); if ($stmt->execute()) { echo json_encode(['status' => 'success']); } else { echo json_encode(['status' => 'error', 'message' => $conn->error]); } $stmt->close(); exit; } } $sql_group_messages = "SELECT gm.message, u.username, gm.sent_at FROM group_messages gm JOIN users u ON gm.user_id = u.id ORDER BY gm.sent_at DESC"; $result_group_messages = $conn->query($sql_group_messages); ?> Group Messages

Welcome, !

Public Chat