public function saveEducationInfoAction()
 {
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     $count = isset($data['COUNT']) ? $data['COUNT'] : 0;
     $info = [];
     for ($i = 0; $i < $count; $i++) {
         $row = [];
         $row['name'] = $data['NAME' . $i];
         $row['start'] = $data['START' . $i];
         $row['end'] = $data['END' . $i];
         $row['visibility'] = $data['VISIBILITY' . $i];
         $info[] = $row;
     }
     if (BuckysUser::updateUserEducationInfo($userID, $info)) {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => 'SUCCESS']];
     } else {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('There was an error to saving your information.')];
     }
     exit;
 }
    buckys_redirect('/index.php');
}
//Getting UserData from Id
$userData = BuckysUser::getUserEducations($userID);
if (isset($_POST['action'])) {
    //Check the user id is same with the current logged user id
    if ($_POST['userID'] != $userID) {
        echo 'Invalid Request!';
        exit;
    }
    //Save Address
    if ($_POST['action'] == 'save_education') {
        $data = [];
        for ($i = 0; $i < count($_POST['schoolname']); $i++) {
            $data[] = ['name' => $_POST['schoolname'][$i], 'start' => $_POST['from'][$i], 'end' => $_POST['to'][$i], 'visibility' => $_POST['visibility'][$i]];
        }
        //Update User Phone numbers
        if (BuckysUser::updateUserEducationInfo($userID, $data)) {
            echo 'Success';
        } else {
            echo $db->getLastError();
        }
        exit;
    }
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('info.css');
buckys_enqueue_javascript('info.js');
$TNB_GLOBALS['content'] = 'info_education';
$TNB_GLOBALS['title'] = "Education - " . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";