Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

delete_blog.php 824B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. require_once('../includes/config.php');
  3. //check to see that the form has been submitted
  4. $id = 0;
  5. if(isset($_POST) && $logged_in)
  6. {
  7. $id = rawurldecode($_POST['id']);
  8. $post = $db->select('blog', "id=? LIMIT 1", array($id));
  9. if ($post)
  10. {
  11. $success = true;
  12. $userID = $post['user_id'];
  13. if($success && (($userID == 0 && !$user->admin) || ($userID != 0 && ($user->id != $userID && !$user->admin))))
  14. {
  15. $error = "You are not allowed to delete this post.";
  16. $success = false;
  17. }
  18. if ($success)
  19. {
  20. $db->delete('blog', 'id=?', array($id));
  21. echo "true";
  22. }
  23. else
  24. {
  25. echo $error;
  26. }
  27. }
  28. else
  29. {
  30. echo "That blog post does not exist.";
  31. }
  32. }
  33. else
  34. {
  35. echo "You need to be logged in to delete this post.";
  36. }
  37. ?>