<?php
include "config.php";

if (isset($_POST['social_id']) && isset($_POST['status'])) {
    $id = intval($_POST['social_id']); // use social_id instead of id
    $status = mysqli_real_escape_string($con, $_POST['status']);

    $query = "UPDATE social_media SET status='$status' WHERE id=$id";
    if (mysqli_query($con, $query)) {
        // Redirect back to socialmedia.php (keep platform in URL if needed)
        $platform = isset($_POST['platform']) ? urlencode($_POST['platform']) : '';
        header("Location: socialmedia.php?platform=$platform&msg=Status+Updated");
        exit();
    } else {
        echo "Error: " . mysqli_error($con);
    }
}
?>