<?php
require_once 'connection.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $groupId = $_POST['groupId'];
    $userEmail = $_POST['userEmail'];

    // Prepare an insert statement
    $stmt = $conn->prepare("INSERT INTO `groupmembertable` (`groupId`, `userEmail`) VALUES (?, ?)");
    // Bind parameters (two string values)
    $stmt->bind_param("ss", $groupId, $userEmail);

    if ($stmt->execute()) {
        echo "Group member added successfully.";
    } else {
        echo "Error: " . $stmt->error;
    }

    $stmt->close();
}

$conn->close();
?>
