<?php
session_start();
if (!(isset($_SESSION['islogin']) && $_SESSION['islogin'] != '')) {

header ("Location: dilosilogin.php");

}
$menu = $_SESSION['menu'];
include "logo.php";
require "dbconnectdilosi.php";
$usr=$_SESSION['usr'];
if (isset($_POST['submit'])) 
{
  $mitroo=$_POST['mitroo'];
  $rd[1]=$_POST['radio1'];
  $rd[2]=$_POST['radio2'];
 // $rd[3]=$_POST['radio3'];
  //$rd[4]=$_POST['radio4'];
}
$c=0;
for ($i=1;$i<=2;$i++)
{
	if ($rd[$i]<>""){$c++;}
}
echo $c;
if ($c < 2)
{
	echo "ΔΕΝ ΕΧΕΤΕ ΕΠΙΛΕΞΕΙ ΚΑΙ ΤΑ 2 ΣΕΜΙΝΑΡΙΑ - ΞΑΝΑΔΟΚΙΜΑΣΤΕ";
}
else
{
$sql=mysqli_query($con,"select * from dilosisem where mitroo='$usr'" );
if (mysqli_num_rows($sql) == 0)
{
  for ($i=1;$i<=2;$i++)
  {
	  $rbt=$rd[$i];
      mysqli_query($con,"insert into dilosisem (mitroo,semcode) values ('$usr','$rbt' )");  
  }
}  
else
{
	
for ($i=1;$i<=2;$i++)
{  
   $row=mysqli_fetch_array($sql);
   $id=$row['id'];
   echo $rd[$i];
   $rbt=$rd[$i];
   mysqli_query($con,"update dilosisem set semcode='$rbt' where mitroo='$mitroo' and id='$id'" );
}
}
$sql=mysqli_query($con,"select count(semcode) as csem,semcode from dilosisem group by semcode");
while ($row=mysqli_fetch_array($sql))
{
    $cnt=$row['csem'];
	$scode=$row['semcode'];
	mysqli_query($con,"update seminaria set plithos='$cnt' where semcode='$scode'" );	
}

echo "ΟΙ ΕΠΙΛΟΓΕΣ ΚΑΤΑΧΩΡΗΘΗΚΑΝ ΜΕ ΕΠΙΤΥΧΙΑ !";
}
?>
<br /><br /><br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>