<?php require_once('../connection.php');
switch($_REQUEST['FUNCTION']){
default:break;

case "new":
$q=mysqli_query($GLOBALS['con'],"INSERT INTO `diary` VALUES(
NULL, 
'".$_REQUEST['title']."', 
'".$_REQUEST['desc']."', 
'".strtotime($_REQUEST['date_start'])."', 
'".strtotime($_REQUEST['date_end'])."',
'".$_REQUEST['reminder']."', 
'".strtotime($_REQUEST['rdate'])."'
)")or die(mysqli_error());

echo "s";
break;

case "update":
$q=mysqli_query($GLOBALS['con'],"UPDATE `diary` SET
`title`='".$_REQUEST['title']."', 
`desc`='".$_REQUEST['desc']."', 
`date_start`='".strtotime($_REQUEST['date_start'])."', 
`date_end`='".strtotime($_REQUEST['date_end'])."',
`reminder`='".$_REQUEST['reminder']."', 
`rdate`='".strtotime($_REQUEST['rdate'])."'
 WHERE `id`='".$_REQUEST['id']."'")or die(mysqli_error());

echo "s";
break;

case "remove":
$q=mysqli_query($GLOBALS['con'],"DELETE FROM `diary` WHERE `id`='".$_REQUEST['id']."'")or die(mysqli_error());

echo "s";
break;
}

?>