<?php
include "scrinit.php";
include ("logo.php"); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<?php
require("dbconnect.php");
if (isset($_POST['Submit'])) 
{ 
$name=$_SESSION['n'];
$usr=$_SESSION['pmp'];
$flg=$_SESSION['flg'];
$gym=$_SESSION['gym'];
$ekdilo = $_POST['ekdilo'];
$katddk= $_POST['portf'];
$papo = $_POST['perapo'];
$pm = $_POST['permexri'];
$dt = $_POST['dat'];
$code=$_POST['code'];echo $code;

if ($flg == 1) 
{
  $sql=$dbcon->prepare("INSERT INTO ekdilosi (code,onoma,katddk,date,perapo,permexri,teacher) VALUES (?,?,?,?,?,?,?)");
  $sql->execute([$code,$ekdilo,$katddk,$dt,$papo,$pm,$usr]); 
  include "epmathnew.php";	
}
else
{
  $sql=$dbcon->prepare("SELECT  onoma,katddk,date,perapo,permexri,teacher FROM ekdilosi WHERE  onoma=? AND date=?" );	
  $sql->execute([$ekdilo,$dt]);
  $c=$sql->rowCount();
  if ($c>0) 
  { 
    $sq=$dbcon->prepare("UPDATE ekdilosi SET katddk=?,perapo=?,permexri=? WHERE onoma=? AND date=?");
	$sq->execute([$katddk,$papo,$pm,$ekdilo,$dt]);
  }
  include "epilogimathiton.php";
}
} //if post
?>
<br><br> 

</body>
</html>