<?php
    include "db.php";

    header("Content-Type: application/octet-stream");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("content-disposition: attachment;filename=dokument.doc");

    //set up data
    $index = mysqli_escape_string($mysqli, $_GET['id']);

    //insert data
    $sql = "SELECT * FROM document WHERE id='$index'";
    $insert = $mysqli->query($sql);

    while ($row = mysqli_fetch_array($insert)){
        $title = $row['title'];
        $fullContent = $row['content'];
        break;
    }
?>

<html>
    <body>
        <center style="font-size: 35px">
            <?= utf8_decode($title); ?>
        </center>
        <?php
            echo utf8_decode($fullContent);
        ?>
    </body>
</html>
