<?php
session_start();
if(isset($_SESSION['teacher']))
{
    include '../classes/result_class.php';
    $result=new Result();
    $teacher_id=$_SESSION['teacher']['id']; 
    $time=time();
    
    if(isset($_POST['t_remark']) && isset($_POST['ht_remark']) && isset($_POST['result_id']))
    {
        $t_remark=htmlentities($_POST['t_remark']);
        $ht_remark=htmlentities($_POST['ht_remark']);
        $result_id=htmlentities($_POST['result_id']);
        if($result->findRemarks($result_id))
        {
            // Update
            if($result->updateRemarks($result_id, $t_remark, $ht_remark))
            {
                echo 'Remarks Added';
            }
            else
            {
                echo 'Could Not Update Remarks';
            }
        }
        else
        {
            // Update
            if($result->addRemarks($result_id, 'teacher', $teacher_id, $t_remark, $ht_remark, $time))
            {
                echo 'Remarks Added';
            }
            else
            {
                echo 'Could Not Add remarks';
            }
        }
    }
    else
    {
        echo 'Fields Not Set';
    }
} 
  
?>