<?php
include '../../classes/session_class.php';
$session=new Session("../../manage/connection.php");

if(isset($_POST['year']) && isset($_POST['end_year']) && isset($_POST['term']) && isset($_POST['begin']) && isset($_POST['end']) && isset($_POST['session_id']))
{
    
    $year=htmlentities($_POST['year']);
    $end_year=htmlentities($_POST['end_year']);
    $term=htmlentities($_POST['term']);
    $begin=htmlentities($_POST['begin']);
    $end=htmlentities($_POST['end']);
    $session_id=htmlentities($_POST['session_id']);
    
    // 
    if($session->findSessionById($session_id))
    {
         if($session->updateSession($term, $year, $end_year, $begin, $end, $session_id))
         {
             echo 'Session Updated';
         }
         else
         {
             echo 'Could not update session';
         }
    }
    else
    {
        echo "Session Not Exist";
    }
}
else
{
     echo 'Field  not Set';
}
?>