	<?php
include "scrinit.php";
	require "dbconnect.php"; 
	$usr=$_SESSION['usr'];
	echo $usr;
		$datein=$_POST['datein'];
		$dateout=$_POST['dateout'];
		$taxi=$_POST['taxi'];
		$keimeno=$_POST['keimeno']." ".$_POST['acro'];
		$file_name = $_FILES['upfile']['name'];
		echo $file_name;
		$file_size =$_FILES['upfile']['size'];
		$file_tmp =$_FILES['upfile']['tmp_name'];
		$file_type=$_FILES['upfile']['type'];
		$ar=explode('.',$file_name);
		$file_ext=$ar[1];
		$errors= array();
		$extensions= array("pdf","docx","txt");
		if(in_array($file_ext,$extensions)== false)
		{
			 $errors[]="Μόνο αρχεία κειμένου επιτρέπονται.";
		}
		if(empty($errors))
		  {
			 move_uploaded_file($file_tmp,"../epiloges/files/".$file_name);
			 
		  }
		if(!empty($_FILES['upfile']['name'][0]))
		{
			echo "<h1>" . "File ". $_FILES['upfile']['name'] ." uploaded successfully." . "</h1>";
		}
		else
		{
			 echo "Λάθος";	
		}
	 	$q1 = $dbcon->prepare("INSERT INTO anakoinosist (datein,dateout,keimeno,teacher,students,arxeio) 
						 VALUES (?,?,?,?,?,?)");
			$q1->execute([$datein,$dateout,$keimeno,$usr,$taxi,$file_name]);					 
				
		echo 'alert()';
		?>
		  <script type="text/javascript">
		  alert("Η ανακοίνωση καταχωρήθηκε με επιτυχία");
		  window.location.href = '<?php echo $menu; ?>'
		  </script>
		<?php
			

