<?php
session_start();
include "../functions.php";

$sessionID = session_id();

checkAdmin($sessionID);


	if (($_POST["submit"] == 1))
	{
		$idate = $_POST["date"];
		$day = substr($idate, 0, 2);
		$month = substr($idate, 3, 2);
		$year = substr($idate, 6, 4);
		$date = $year . $month . $day;

		$ssubject = $_POST["subject"];
		$sauthor = $_POST["author"];
		$ssummary = $_POST["summary"];
		$sbody = $_POST["body"];
		$surl = $_POST["url"];
		$simage = $_POST["image"];
		$ihighlight = isset($_POST["highlight"])?1:0;
		$categoryID = $_POST["categoryID"];
		
		include "../conn.php";
		
		$query = "insert into news (date, subject, author, summary, body, url, img, highlight, categoryID) values('$date', '$ssubject', '$sauthor', '$ssummary', '$sbody', '$surl', '$simage', '$ihighlight', '$categoryID')";
		
		mysql_query($query);
		//echo $query;
		
		header ("location: newslisting.php");
		//echo "<b>$ssubject</b> record added, <a href=add.php>click here</a> to add more news.";
	}

?>