<?php
session_start();
include('db_connection.php'); // Make sure to include your database connection

// Handle group creation
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['create_group'])) {
    $group_name = $_POST['group_name'];
    $group_description = $_POST['group_description'];
    $group_type = $_POST['group_type'];
    $student_id = $_SESSION['student_id'];

    // Insert the new group into the database
    $query_create_group = "INSERT INTO groups (group_name, group_description, group_type, admin_id) VALUES (?, ?, ?, ?)";
    $stmt_create_group = $conn->prepare($query_create_group);
    $stmt_create_group->bind_param("sssi", $group_name, $group_description, $group_type, $student_id);

    if ($stmt_create_group->execute()) {
        echo "Group created successfully!";
    } else {
        echo "Error: " . $conn->error;
    }

    $stmt_create_group->close();
}

?>
