<?php
session_start(); 
$menu=$_SESSION['menu'];
include $menu;
?>
<!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" />
<title>Untitled Document</title>
</head>

<body>
<br>
<h3> ΔΗΛΩΣΗ ΗΜΕΡΟΜΗΝΙΩΝ </h3>
<?php
require("dbconnect.php");

$dt=$_SESSION['dt'];

echo "<BR>"."<b>"."EΠΕΛΕΞΕ ΠΡΟΓΡΑΜΜΑ :"."</b>"."<br>";

$sql = "SELECT programma FROM limitsdb ORDER BY code";
$result = mysqli_query($con,$sql);
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  } 
?>
<form  method="post"   > 

<?php


$i=2;
echo "<select name='prog'>";

$program[1]="ΝΕΑ ΕΓΓΡΑΦΗ";
echo "<option value ='".$program[1]."'>".$program[1]."</option>";
while ($row = mysqli_fetch_array($result)) 
{
	$program[$i]=$row['programma'];
   	echo "<option value ='".$program[$i]."'>".$program[$i]."</option>";
	$i++;
}
echo "</select>";
?>	
<input type="Submit" name="prg" value="Επιλογή programmatos" >

</form>	

<?php

if (isset($_POST['prog'])) 
{
$programma=" ";
$flg=1;
$_SESSION['flg']=$flg;
$programma=$_POST['prog'];
if ($programma != "ΝΕΑ ΕΓΓΡΑΦΗ")
{
$sql = "SELECT code,programma,datestart,dateend,timestart,timeend FROM limitsdb WHERE programma='$programma'";
$result = mysqli_query($con,$sql);	
$row = mysqli_fetch_array($result);
$code=$row['code'];
$datestart = $row['datestart'];
$dateend=$row['dateend'];
$timestart = $row['timestart'];
$timeend = $row['timeend'];
$prog = $programma;
$flg=2;
$_SESSION['flg']=$flg;

}
else $prog=" ";

?>
<br /><br /><h3>ΣΤΟΙΧΕΙΑ ΕΚΔΗΛΩΣΗΣ:<?php echo $programma;  ?></h3>

<form  method="post" action = "setdatelimits1.php" > 
<fieldset style="width: 600px; ">
<br > ΠΡΟΓΡΑΜΜΑ  :<input type='text' name='programma'  value="<?php echo $prog; ?>" /> <br > 
<br > ΚΩΔΙΚΟΣ.  :<input type='number' name='code' value ="<?php echo $code; ?>"  /> 

<br > ΑΠΟ ΗΜΕΡΟΜΗΝΙΑ :<input type="date"  name = 'datestart' value= <?php echo $datestart; ?> >
ΑΠΟ ΩΡΑ :<input type="text"  name = 'timestart' value= <?php echo $timestart; ?> > 
<br > ΜΕΧΡΙ ΗΜΕΡΟΜΗΝΙΑ:<input type="date"  name = 'dateend' value= <?php echo $dateend; ?> ><br > 
ΜΕΧΡΙ ΩΡΑ :<input type="text"  name = 'timeend' value= <?php echo $timeend; ?> > 

<input type="Submit" name="Submit" value="Καταχώρηση" >
</fieldset>
</form>	

<?php
}

?>
<br /><br /><br /><br />
<a  href=<?php echo $menu; ?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>