website/public/newComment.php

16 lines
546 B
PHP

<?php
include("./internal/mysql.php");
$ref = $_SERVER["HTTP_REFERER"];
$article = $conn->escape_string(explode(".php", explode("Projekte/", $ref)[1])[0]);
$name = $conn->escape_string($_POST["name"]);
$email = $conn->escape_string($_POST["email"]);
$comment = $conn->escape_string($_POST["comment"]);
$sql = "INSERT INTO comments (name, email, comment, article) VALUES ('$name', '$email', '$comment', '$article')";
if ($conn->query($sql) === TRUE) {
header("Location: $ref");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}