<?php
include "scrinit.php";
  
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=800, height=800, top='+top+', left='+left);
}
</script>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:9pt; }
<p style="font-size:09px;"></p>

</style>
</head>
<body>

<?php

require("dbconnect.php");
$stname=$_POST['stname'];
echo "ΜΑΘΗΤΗΣ/ΤΡΙΑ: ".$stname."<br>";
$vdidk=$_SESSION['vdidk'];
$fuser=$_SESSION['fuser'];
$tmimaid=$_SESSION['tmimaid'];
$mitr= $_POST['mitroo'];	
$error = false;
if (!strlen(trim($_POST['perigrafi']))) {
    $error = true;
  }

if ($error) // DISPALY A MESSAGE BOX IF FIELDS ARE EMPTY
{  
   echo '<script type="text/javascript">';
   echo 'alert("ΠΡΕΠΕΙ ΑΠΑΡΑΙΤΗΤΑ ΝΑ ΔΩΣΕΤΕ ΠΕΡΙΓΡΑΦΗ ΓΙΑ ΤΟ ΠΑΡΑΠΤΩΜΑ")';
   echo '</script>';	
   $time = 1; //Time (in seconds) to wait. 
   //$url = "dispkataggeliakath.php?pmp=".$mitr; //Location to send to. 
   $url = "pitharxika.php"; //Location to send to.
   header("Refresh: $time; url=$url");

} 
else 
{
$mitr=      $_POST['mitroo'];	
$kataggelon= $_POST['kathig'];
$datekata= $_POST['datekata'];
$perigrafi=$_POST['perigrafi'];
$sxolia=$_POST['sxolia'];
$arsimp = $_POST['arsimpx'];
$datetimo = $_POST['datetimo'];
$eidostimo = $_POST['eidostimo'];
$periodoi = $_POST['periodoi'];
$katastasi = $_POST['katastasi'];
$flag=$_POST['flag'];
$aranaforas=$_POST['aranaforas'];

$sql="INSERT INTO kataggelia (mitroo,tmima,bd,kataggelon,datekata,perigrafi,
                  sxolia,arsimperiforas) 
	VALUES ('$mitr','$tmimaid','$vdidk','$kataggelon','$datekata','$perigrafi','$sxolia','$arsimp') ";

   if (mysqli_query($con, $sql)) 
	{
			 echo "Η καταγγελία καταχωρήθηκε με αριθμό: ".$aranaforas;
   			 echo "<br>"."<br>";
        } 
	else 
	{
            echo "Error: " . $sql . "<br>" . mysqli_error($con);
        }
	
   }


   echo '<script type="text/javascript">';
   echo 'alert("Η καταγγελία καταχωρήθηκε/ενημερώθηκε με τη νέα κατάσταση")';
   echo '</script>';	
   $time = 0.5; //Time (in seconds) to wait. 
   $url = "pitharxika.php"; //Location to send to. 
   header("Refresh: $time; url=$url");

?>	



</body>
</html>