<?php
session_start();
$username = $_SESSION['membership'];
include("connect.php");
$saOwner = $_POST["ID"];
$saComment = $_POST["saComment"];
$date = date("Y-m-d H:m:s"); 
$articleNo = $_POST["articleNo"];
	
if($_POST["Delete"] == "Delete")
	{
	$query="delete from spacearticle where memLname='$ISBN' && memLname = '$username'";
	$result = $db->query($query);
	$db->close();
	echo "<script language='javascript'>alert('Your comment is deleted.')</script>";
	echo "<script language='javascript'>window.location='spacearticle.php?saTitle=$articleNo&&membername=$saOwner'</script>";
}else{
	$query = "INSERT INTO articlecomment(articleNo,saOwner,memLname,saTime,saComment)
	VALUES
	('$articleNo','$saOwner','$username','$date','$saComment')";
	$result = $db->query($query);
	$db->close();
	echo "<script language='javascript'>alert('Thanks for your comment.')</script>";
	echo "<script language='javascript'>window.location='spacearticle.php?saTitle=$articleNo&&membername=$saOwner'</script>";
}
?>