I am trying that the user who is logged in can delete his own posts so only he should see the delete button on his posts. I was thinking by my own that I had to bind the user who is logged in to the posts/img ID and then he should see the button. I'm struggling with this a bit so every useful comment is appreciated!
PHP
<?php
$result = $mysqli->query("SELECT users.user_id, users.username,
picas.img_id, picas.user_id, picas.name, picas.description, picas.created_at
FROM users
JOIN picas ON users.user_id = picas.user_id
ORDER BY picas.created_at DESC");
while($pica = $result->fetch_assoc()) {
$ses_user = $_SESSION['username'];
echo '<div class="image_post">';
if(isset($ses_user) == $pica['user_id'] && $pica['img_id']) {
echo '<form action="logic/delete_post.php?id='.$pica['img_id'].'" method="POST">
<input type="hidden" name="id" value="?id='.$pica['img_id'].'" />
<input type="submit" name="deleteSubmit" value="Delete" class="delete_post" />
</form>';
}
echo '<div class="user_avatar"><img src="avatars/'.$pica['username'].'.jpeg" /></div>
<div class="user_name">'.$pica['username'].'</div> <br><br><br><br>
<div class="timeago">'.$diff.'</div>
<div class="image_description">'.$pica['description'].'</div>
<img src="'.$pica['name'].'" />
<div class="clear"></div>
</div>';
}
?>