删除用户文章并限制删除作者的文章

bxgwgixi  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(185)

我一直在开发一个php脚本,可以从我的博客中删除文章。但现在,每个人都可以删除每个人的帖子,如果他们登录。我想限制这对作者的帖子,所以他们只能删除自己的帖子。我怎样才能做到这一点?
我的index.php是这样的:

  1. <script language ="JavaScript" type="text/javascript">
  2. function delpost(id, title) {
  3. if (confirm("Are you sure you want to delete '" + title + "'")) {
  4. window.location.href = 'index.php?delpost=' + id;
  5. }
  6. }
  7. </script>
  8. <?php
  9. try {
  10. $author = $_SESSION['author'];
  11. $stmt = $db->query('SELECT postID, postTitle,postAlttext, postDesc, postDate, postAlttext, postImage, author FROM blog_posts ORDER BY postID DESC');
  12. while ($row = $stmt->fetch()) {
  13. echo '<span style="float: right"><a href="edit-post.php?id='.$row['postID'].'"><i class="material-icons" style="font-size:36px;color:black">border_color</i></a></span>';?>
  14. <a href="javascript:delpost('<?php echo $row['postID'];?>','<?php echo $row['postTitle'];?>')"><i class="material-icons" style="font-size:36px;color:red">delete</i></a>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题