Skip to content
Snippets Groups Projects
Commit be57ada3 authored by Jonas Leder's avatar Jonas Leder
Browse files

get page name for new comments from frontend

parent 34fd22da
No related branches found
No related tags found
No related merge requests found
Pipeline #1640 passed
...@@ -14,6 +14,7 @@ class newComment extends HTMLElement { ...@@ -14,6 +14,7 @@ class newComment extends HTMLElement {
script.src = "https://hCaptcha.com/1/api.js"; script.src = "https://hCaptcha.com/1/api.js";
script.type = 'text/javascript'; script.type = 'text/javascript';
script.onload = () => { script.onload = () => {
let pageName = path.split("/").pop();
this.parentElement.innerHTML = ` this.parentElement.innerHTML = `
<form action="/API/newComment.php" method="post"> <form action="/API/newComment.php" method="post">
<label for="name">Name:</label><br> <label for="name">Name:</label><br>
...@@ -27,6 +28,7 @@ class newComment extends HTMLElement { ...@@ -27,6 +28,7 @@ class newComment extends HTMLElement {
<div class="h-captcha" data-theme="dark" data-sitekey="${sitekey}"></div><br> <div class="h-captcha" data-theme="dark" data-sitekey="${sitekey}"></div><br>
<input type="hidden" name="pagename" id="pagename" value="${pageName}">
<input type="submit" value="Kommentar ver&ouml;ffentlichen"><br> <input type="submit" value="Kommentar ver&ouml;ffentlichen"><br>
<p>Mit dem Klick auf den obigen Button erkl&auml;ren sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerkl&auml;rung</a> einverstanden.</p> <p>Mit dem Klick auf den obigen Button erkl&auml;ren sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerkl&auml;rung</a> einverstanden.</p>
</form> </form>
...@@ -36,4 +38,4 @@ class newComment extends HTMLElement { ...@@ -36,4 +38,4 @@ class newComment extends HTMLElement {
} }
} }
customElements.define("jl-new_comment", newComment); customElements.define("jl-new_comment", newComment);
\ No newline at end of file
...@@ -22,8 +22,7 @@ $responseData = json_decode($response->getBody()); ...@@ -22,8 +22,7 @@ $responseData = json_decode($response->getBody());
if($responseData->success) { if($responseData->success) {
$ref = $_SERVER["HTTP_REFERER"]; $article =$conn->escape_string($_POST["pagename"]);
$article = $conn->escape_string(explode(".php", explode("Projekte/", $ref)[1])[0]);
$name = $conn->escape_string($_POST["name"]); $name = $conn->escape_string($_POST["name"]);
$email = $conn->escape_string($_POST["email"]); $email = $conn->escape_string($_POST["email"]);
$comment = $conn->escape_string($_POST["comment"]); $comment = $conn->escape_string($_POST["comment"]);
...@@ -37,4 +36,4 @@ if($responseData->success) { ...@@ -37,4 +36,4 @@ if($responseData->success) {
} }
} else { } else {
echo "Failed to verify captcha."; echo "Failed to verify captcha.";
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment