<?php
session_start();

//$title = "edit news";
//include "header.php";

include "../conn.php";

$id = $_POST["id"];
$categoryID = $_POST["categoryID"];
$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;

$query = "update news set date='$date', subject='$ssubject', author='$sauthor', summary='$ssummary', body='$sbody', url='$surl', img='$simage', highlight='$ihighlight', categoryID='$categoryID' where id='$id'";

//echo $query;
mysql_query($query) or die (mysql_error());

header ("location: newslisting.php");
echo "news updated successfully<br>";
//echo "<a href=admin.php>admin main page</a>";
//include "footer.php";
?>