<?php

require_once("includes/SQLConnect.php");
require_once("includes/classes/Comments.inc.php");
require_once("includes/user_data.php");

//This page just processes posts that are being submitted to the form on the forum_view_topic page. People get bounced back to that page after posting.
//This will probably be replaced with AJAX.


if((int)$_POST['forum_topic_ID']>0)
	if(strlen($_POST['body'])>0){
		$Comments = new Comments($user_data['ID'],0,(int)$_POST['forum_topic_ID']);
		if($Comments->newComment($_POST['body']))
			header("Location:forum_view_topic.php?ID=".(int)$_POST['forum_topic_ID']."&success=Your comment has been added to the discussion.#comment".$Comments->comment_ID);
		else
			$error = "Duplicate comment presumably but could be another error (maybe?).";
	}
	else
		$error = "You can't write a blank comment.";
else
	$error = "There was no forum_topic_ID submitted. This won't happen either.";

?>