<?php
require_once "conn.php";


if ($_SERVER["REQUEST_METHOD"] == "POST") {
  
    if (isset($_POST["id"]) && !empty($_POST["id"])) {
       
        $id = $_POST["id"];

       
        $stmt = $conn->prepare("UPDATE artikel SET hit = hit + 1 WHERE id = ?");
        $stmt->bind_param("i", $id);

        if ($stmt->execute()) {
            
            $response["status"] = "success";
            $response["message"] = "Hit value updated successfully.";
            echo json_encode($response);
        } else {
            
            $response["status"] = "error";
            $response["message"] = "Failed to update hit value.";
            echo json_encode($response);
        }

        
        $stmt->close();
    } else {
        
        $response["status"] = "error";
        $response["message"] = "Invalid data provided.";
        echo json_encode($response);
    }
} else {
    
    $response["status"] = "error";
    $response["message"] = "Invalid request method.";
    echo json_encode($response);
}
?>
