added comment publish function

This commit is contained in:
Jonas Leder 2020-10-27 13:46:22 +01:00
parent c0ecd271b0
commit cff371031c
3 changed files with 53 additions and 1 deletions

View file

@ -65,8 +65,24 @@ include "../internal/mysql.php";
<img src="/img/Nexus_6P_-_Screenshot_21-576x1024.png"> <img src="/img/Nexus_6P_-_Screenshot_21-576x1024.png">
<img src="/img/Nexus_6P_-_Screenshot_31-576x1024.png"> <img src="/img/Nexus_6P_-_Screenshot_31-576x1024.png">
<img src="/img/Nexus_6P_-_Screenshot_41-576x1024.png"> <img src="/img/Nexus_6P_-_Screenshot_41-576x1024.png">
<h2>Kommentare:</h2>
<div id="newComment">
<form action="/newComment.php" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br>
<label for="email">E-Mail: (wird nicht ver&ouml;ffentlicht)</label><br>
<input type="text" id="email" name="email"><br><br>
<label for="comment">Kommentar:</label><br>
<textarea name="comment" id="comment"></textarea><br><br>
<input type="submit" value="Kommentar ver&ouml;ffentlichen"><br>
<p>Mit dem klick auf den obigen Button erklären sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerkl&auml;rung</a> einverstanden.</p>
</form>
</div>
</div> </div>
</div> </div>
<footer includeHTML="/include/footer.php"> <footer includeHTML="/include/footer.php">

View file

@ -404,3 +404,23 @@ button{
text-decoration: none; text-decoration: none;
color: #1cb09a; color: #1cb09a;
} }
#newComment form input, #newComment form textarea{
width: 100%;
background: #1a2332;
color: #b3b3b3;
border: solid #212a39;
}
#newComment form textarea{
resize: vertical;
}
#newComment form input[type=submit]{
background: #1cb09a;
color: #fff;
text-transform: uppercase;
padding: 15px;
font-size: 14px;
cursor: pointer;
outline: 0;
border: 0;
}

16
newComment.php Normal file
View file

@ -0,0 +1,16 @@
<?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;
}