<?php
chdir('../../');
require_once 'autoload.php';
$types = new exam_types_controller;

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['csrf_token']) && isset($_POST['csrf_form_id']) && $waf->csrf_validate($_POST['csrf_form_id'], $_POST['csrf_token'], $utility->action_name())) {

$sanitezed_data = $utility->sanitize_request($_POST);

if (empty($types->check($sanitezed_data['code'], $_POST['id']))) {

$types->update($_POST['id'], $sanitezed_data);

$utility->setMessage("success", 'Exam type updated');

header("location:../exam_types");

}else{

$utility->setMessage("warning", 'Exam type is already registered');

header("location:../exam_types");

}
}else{

header("location:../exam_types");

}
?>
