get page name for new comments from frontend
This commit is contained in:
parent
34fd22da24
commit
be57ada3fa
2 changed files with 5 additions and 4 deletions
|
@ -14,6 +14,7 @@ class newComment extends HTMLElement {
|
|||
script.src = "https://hCaptcha.com/1/api.js";
|
||||
script.type = 'text/javascript';
|
||||
script.onload = () => {
|
||||
let pageName = path.split("/").pop();
|
||||
this.parentElement.innerHTML = `
|
||||
<form action="/API/newComment.php" method="post">
|
||||
<label for="name">Name:</label><br>
|
||||
|
@ -27,6 +28,7 @@ class newComment extends HTMLElement {
|
|||
|
||||
<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öffentlichen"><br>
|
||||
<p>Mit dem Klick auf den obigen Button erklären sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerklärung</a> einverstanden.</p>
|
||||
</form>
|
||||
|
@ -36,4 +38,4 @@ class newComment extends HTMLElement {
|
|||
}
|
||||
}
|
||||
|
||||
customElements.define("jl-new_comment", newComment);
|
||||
customElements.define("jl-new_comment", newComment);
|
||||
|
|
|
@ -22,8 +22,7 @@ $responseData = json_decode($response->getBody());
|
|||
|
||||
if($responseData->success) {
|
||||
|
||||
$ref = $_SERVER["HTTP_REFERER"];
|
||||
$article = $conn->escape_string(explode(".php", explode("Projekte/", $ref)[1])[0]);
|
||||
$article =$conn->escape_string($_POST["pagename"]);
|
||||
$name = $conn->escape_string($_POST["name"]);
|
||||
$email = $conn->escape_string($_POST["email"]);
|
||||
$comment = $conn->escape_string($_POST["comment"]);
|
||||
|
@ -37,4 +36,4 @@ if($responseData->success) {
|
|||
}
|
||||
} else {
|
||||
echo "Failed to verify captcha.";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue