<?php
include("../config/db.php");
if(!isset($_SESSION['user_id'])) header("Location: login.php");
$article_id=intval($_POST['article_id']);
$user_id=$_SESSION['user_id'];
$comment=trim($_POST['comment']);
if($comment){
    $stmt=$conn->prepare("INSERT INTO comments (article_id,user_id,content) VALUES (?,?,?)");
    $stmt->bind_param("iis",$article_id,$user_id,$comment);
    $stmt->execute();
}
header("Location: article.php?id=$article_id"); exit;
?>
