<?php
$parent = isset($_GET["parent"]) ? $_GET["parent"] : null;
$kmomNames = [
    "kmom01" => "Kursmoment 1",
    "kmom02" => "Kursmoment 2",
    "kmom03" => "Kursmoment 3",
    "kmom04" => "Kursmoment 4",
    "kmom05" => "Kursmoment 5",
    "kmom06" => "Kursmoment 6",
    "kmom07" => "Kursmoment 7-10"
];
$allowedParents = [ "kmom01", "kmom02", "kmom03", "kmom04", "kmom05", "kmom06", "kmom07" ];
if (!isset($parent) || !in_array($parent, $allowedParents)) {
    header("Location: {$_SERVER["HTTP_REFERER"]}");
}
$action = null;
if ($_SERVER["HTTP_HOST"] == "rasmussteen.com") {
     $action = "/me/comments/process-comment.php";
} else {
    $action = "/~rasb14/dbwebb-kurser/htmlphp/me/kmom05/me5/comments/process-comment.php";
}
?>
<h4>Komenterar <?= $kmomNames[$parent] ?></h4>
<form method="post" action="<?= $action ?>">
    <input type="hidden" name="referer" value="<?= $_SERVER["HTTP_REFERER"] ?>">
    <input type="hidden" name="parent" value="<?= $parent ?>">
    <input type="text" name="name" placeholder="Skriv ditt namn här."><br />
    <textarea name="text" rows="3" cols="100" maxlength="255" placeholder="Skriv din kommentar här."></textarea><br />
    <input type="submit" value="Skicka">
</form>
