<?php

			include '../connection.php'; /** calling of connection.php that has the connection code **/
			
				
						/*** Putting all the data from text into variables **/
				
				$title = $_POST['title']; 
				$details = $_POST['details'];
				$image = $_FILES['image']['name'];
				$temp = explode(".",$_FILES["image"]["name"]);
				$t=time();
				$newfilename = $t . '.' .end($temp);
				echo '<br>';
				
				$target_path = '../events/event_img/';
				$target_path = $target_path . $newfilename; 

				if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path )) {
					echo "The file ".  basename( $_FILES['image']['name']).   " has been uploaded";
				} else{
					echo "There was an error uploading the file, please try again!";
				}
				
				mysql_query("INSERT INTO event(event_title,event_detail,event_image) 
							VALUES('$title','$details','$newfilename')") 
							or die(mysql_error()); /*** execute the insert sql code **/
							
				echo "<div class='alert alert-info'> Successfully Saved. </div>"; /** success message **/

		?>