<?php
session_start();
error_reporting(0);
include_once("sessionMenus.php");
include_once("connection.php");	

date_default_timezone_set('Asia/Kolkata');	
$date=$_POST['date'];
$final_dest='userdata/news';
  if(is_dir( $final_dest)==FALSE){
		mkdir($final_dest,0777,TRUE);
	}
	copy('temp/'.$_SESSION['sm_img'],$final_dest.'/'.$_SESSION['sm_img']);
	
$title=str_replace("'","^",$_POST['pro_cat']);
$poster=str_replace("'","^",$_POST['poster']);
$about=str_replace("'","^",$_POST['about']);

$sql= "INSERT INTO tbl_news (title,imagename,newsdatetime,newscontent,smalldescp) VALUES('".$title."','".$_SESSION['sm_img']."',STR_TO_DATE('$date','%d/%m/%Y'),'".$about."','".$poster."')";
	
$exec_query=mysqli_query($conn, $sql);

if($exec_query){
	$result=1;
}
else
{
	$result=0;	
}


$json = array("op" =>$result);
			
			// send data as json format
			header("Content-Type: application/json",true);
				echo json_encode($json); 
				
?>