add basic post functionality
This commit is contained in:
16
website/public/API/postComment.php
Normal file
16
website/public/API/postComment.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require("../../queries/post.php");
|
||||||
|
require("../../queries/connect.php");
|
||||||
|
require("../../queries/checkInput.php");
|
||||||
|
|
||||||
|
if (empty($_POST['newcomment-content'])) {
|
||||||
|
} else {
|
||||||
|
makeComment($_POST['postID'],
|
||||||
|
$_SESSION['userID'],
|
||||||
|
test_input($_POST['newcomment-content']));
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: ../profile.php");
|
||||||
17
website/public/API/postPost.php
Normal file
17
website/public/API/postPost.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require("../../queries/post.php");
|
||||||
|
require("../../queries/connect.php");
|
||||||
|
require("../../queries/checkInput.php");
|
||||||
|
|
||||||
|
if (empty($_POST['newpost-title'])) {
|
||||||
|
} else {
|
||||||
|
makePost($_SESSION['userID'],
|
||||||
|
null,
|
||||||
|
test_input($_POST['newpost-title']),
|
||||||
|
test_input($_POST['newpost-content']));
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: ../profile.php");
|
||||||
@@ -76,7 +76,7 @@ function makePost($userID, $groupID, $title, $content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeComment($postID, $userID, $content) {
|
function makeComment($postID, $userID, $content) {
|
||||||
$stmt = $_GLOBAL["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`comment` (
|
`comment` (
|
||||||
`postID`,
|
`postID`,
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ echo("
|
|||||||
|
|
||||||
<div class='post-comments'>
|
<div class='post-comments'>
|
||||||
<div class="commentfield">
|
<div class="commentfield">
|
||||||
<form name="newcomment" method="post">
|
<form action="API/postComment.php" name="newcomment" method="post">
|
||||||
<textarea placeholder="Laat een reactie achter..."></textarea> <br>
|
<input type="hidden" name="postID" value="<?= $postID ?>">
|
||||||
|
<textarea name="newcomment-content" Laat een reactie achter..."></textarea> <br>
|
||||||
<input type="submit" value="Reageer!">
|
<input type="submit" value="Reageer!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -58,9 +58,9 @@
|
|||||||
if ($_SESSION["userID"] === $userID) {
|
if ($_SESSION["userID"] === $userID) {
|
||||||
?>
|
?>
|
||||||
<div class="post platform">
|
<div class="post platform">
|
||||||
<form>
|
<form action="API/postPost.php" method="post">
|
||||||
<input type="text" class="newpost" placeholder="Titel">
|
<input type="text" name="newpost-title" class="newpost" placeholder="Titel">
|
||||||
<textarea class="newpost" placeholder="Schrijf een berichtje..."></textarea>
|
<textarea class="newpost" name="newpost-content" placeholder="Schrijf een berichtje..."></textarea>
|
||||||
<input type="submit" value="Plaats!">
|
<input type="submit" value="Plaats!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user