<?php

include 'connect.php';

$id=intval($_POST['id']);
$name=$_POST['name'];
$comment=$_POST['comment'];


$sql="INSERT INTO comments (commentName, commentText, uploadNo) VALUES (?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('ssi', $name, $comment, $id);


if ($result = $stmt->execute())
  {
  echo '1 record added.' . '</br>';
  echo 'id: ' . htmlentities($id, ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' comment: ' . htmlentities($comment, ENT_QUOTES | ENT_HTML5, 'UTF-8')  . ' name: ' . htmlentities($name, ENT_QUOTES | ENT_HTML5, 'UTF-8');

  }
else{
  echo 'update failed.' . $conn->error . '</br>';
  }

echo "<script>window.history.back();</script>";

?>
