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.

add_comment.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. require_once('../includes/config.php');
  3. $post_id = 0;
  4. $title = "";
  5. $comment = "";
  6. //check to see that the form has been submitted
  7. if(isset($_POST))
  8. {
  9. //retrieve the $_POST variables
  10. $post_id = rawurldecode($_POST['postID']);
  11. $service = rawurldecode($_POST['service']);
  12. $comment = rawurldecode($_POST['comment']);
  13. //initialize variables for form validation
  14. $success = true;
  15. if($success && !$logged_in)
  16. {
  17. $error = "You must be logged in to make a comment.";
  18. $success = false;
  19. }
  20. if($success && empty($comment))
  21. {
  22. $error = "You need to submit an actual comment.";
  23. $success = false;
  24. }
  25. if($success)
  26. {
  27. $data = array(
  28. "service" => $service,
  29. "reply_id" => $post_id,
  30. "user_id" => $user->id,
  31. "title" => $title,
  32. "post" => $comment,
  33. "date_posted" => date("Y-m-d H:i:s",time())
  34. );
  35. $post_id = $db->insert($data, 'comments');
  36. unset($_POST);
  37. echo "true";
  38. }
  39. else
  40. {
  41. unset($_POST);
  42. echo $error;
  43. }
  44. }
  45. else
  46. {
  47. echo "$_POST is not set.";
  48. }
  49. ?>