<?php
error_reporting(E_ALL);
require_once("../SQLConnect.php");
require("../user_data.php");
require("../classes/Comments.inc.php");
require_once("../functions.php");

$user_ID = (int)$user_data['ID'];
$site_area_ID = (int)$_POST['ID'];
$body = htmlentities(strip_tags($_POST['body']));

$sql = "INSERT INTO Comments(user_ID,body,site_area_ID) VALUES(".$user_ID.",'".mysql_real_escape_string($body)."',".$site_area_ID.")";

if(mysql_query($sql)){

	$Comments = new Comments($user_ID,$site_area_ID,0);
	$comment = $Comments->getComment(mysql_insert_id());
	
	?>
		<li>
			<?=htmlentities(strip_tags(stripslashes($comment['body'])));?>
			<div class='attribution'>
				<b><?=$comment['first_name'].' '.$comment['last_name'];?></b> - <?=format_datetime($comment['timestamp']);?>
			</div>
		</li>	
	<?php
}
?>