PHP Classes

File: php/add-comment.php

Recommend this page to a friend!
  Classes of Ann   Purp Project   php/add-comment.php   Download  
File: php/add-comment.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Purp Project
Application to manage photo albums
Author: By
Last change: Update of php/add-comment.php
Date: 1 year ago
Size: 1,332 bytes
 

Contents

Class file image Download
<?php

//add_comment.php
session_start();
require_once
'includes/connect-db.php';

$error = '';
$comment_name = '';
$comment_content = '';
$parent_ID = $_POST["comment_id"];

$user_ID = $_SESSION['user']['id'];
$pic_ID = $_SESSION['pic']['id'];
$date = date('Y-m-d H:i:s');

// if(empty($_POST["comment_name"]))
// {
// $error = '<p class="text-danger">Name is required</p>';
// }
// else
// {
  
// $comment_name = $_POST["comment_name"];
// }

if(empty($_POST["comment_content"]))
{
 
$error .= '<p class="text-danger">Comment is required</p>';
}
else
{
 
$comment_content = $_POST["comment_content"];
}

if(
$error == '')
{
// INSERT INTO `comments`(`id`, `user-id`, `pic-id`, `date`, `text`, `parent-id`) VALUES ('[value-1]','[value-2]','[value-3]','[value-4]','[value-5]','[value-6]')
// $date = date('Y-m-d H:i:s');
// $pic_id = $_SESSION['pic']['id'];
$query = "INSERT INTO `comments`(`id`, `user-id`, `pic-id`, `date`, `text`, `parent-id`)
VALUES (NULL,'
$user_ID','$pic_ID','$date','$comment_content','$parent_ID')
 "
;
 
$result = mysqli_query($connect, $query) or die("?????? " . mysqli_error($connect));


 
$error = '<label class="text-success">Comment Added</label>';
}


$data = array(
   
'error' => $error
  
);
  
   echo
json_encode($data);
  

?>