<?php 	

require_once '../../Server/connection.php';

$valid['success'] = array('success' => false, 'messages' => array());

if($_POST) {	

	$editDepartName = $_POST['editDepartName'];
    $deptId = $_POST['editCategoriesId'];

	$sql = "UPDATE departments SET depart_name = '$editDepartName' WHERE dept_id = '$deptId'";

	if($conn->query($sql) === TRUE) {
	 	$valid['success'] = true;
		$valid['messages'] = "Successfully Updated";	
	} else {
	 	$valid['success'] = false;
	 	$valid['messages'] = "Error while updating Department";
	}
	 
	$conn->close();

	echo json_encode($valid);
 
} // /if $_POST