<?php

    $db = new PDO(
        "mysql:host=localhost;dbname=class_blog",
        "class_user",
        "class_password"
    );

    $insert_comment_query = $db->prepare("
        INSERT INTO `comments`
            (`postid`, `author`, `comment`)
        VALUES
            (:postid, :author, :comment)
    ");

    $params = array(
        ':postid' => $_POST['postid'],
        ':author' => $_POST['name'],
        ':comment' => $_POST['message']
    );

    $insert_comment_query->execute($params);

    header("Location: blog_comments.php?postid=" . $_POST['postid']);


?>
