<?php
include ("connect.php");
$username = $_SESSION['staff'];

$eventDate = $_POST["eventDate"];
$eventTime = $_POST["eventTime"];
$eventLocation = $_POST["eventLocation"];
$eventTitle = $_POST["eventTitle"];
$eventDescription = $_POST["eventDescription"];

	$result = mysql_query("INSERT INTO companyevent(eventDate,eventTime,eventLocation,eventTitle,eventDescription)
	VALUES
	('$eventDate', '$eventTime', '$eventLocation', '$eventTitle', '$eventDescription')");
	
	
	$tmp_file_name = $_FILES['file']['tmp_name']; 
	$file_name = $_FILES['file']['name']; 
	$file_dir = './event/'.$_POST['title'].'/';  
	if(is_dir($file_dir)) 
	{ 
	move_uploaded_file($tmp_file_name,$file_dir.$file_name); 
	$img_url = $file_dir.$file_name; 

	$result = mysql_query("UPDATE companyevent SET eventImage = '$img_url' WHERE eventTitle = '$eventTitle'");
	
	
	$db = mysql_close();
	echo "<script language='javascript'>alert('Insert success.')</script>";
	echo "<script language='javascript'>window.location='event.php'</script>";
	}
?>	