<?php
session_start();
ob_start();
if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΕΓΓΡΑΦΕΙΤΕ ΓΙΑ ΝΑ ΧΡΗΣΙΜΟΠΟΙΗΣΕΤΕ ΤΟ ΣΥΣΤΗΜΑ"."<BR>";
  sleep(3);
  header("Location: loginall.php"); /* Redirect browser */
  exit();
  }
$menu = $_SESSION['menu'];
include "logo.php";
require "dbconnect.php";

if (isset($_POST['submit'])) 
{
  $mitroo=$_POST['mitroo'];
  $rd[1]=$_POST['radio1'];
  $rd[2]=$_POST['radio2'];
  $rd[3]=$_POST['radio3'];
  $rd[4]=$_POST['radio4'];
}

$sql=mysqli_query($con,"select * from dilosisem where mitroo='$mitroo'" );
if (mysqli_num_rows($sql) == 0)
{
  
  for ($i=1;$i<=4;$i++)
  {
	  
      mysqli_query($con,"insert into dilosisem (id,mitroo,semcode) values ('$mitroo','$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'" );
}
}
echo "ΟΙ ΕΠΙΛΟΓΕΣ ΚΑΤΑΧΩΡΗΘΗΚΑΝ ΜΕ ΕΠΙΤΥΧΙΑ !";
?>