// Reset error level
$error_level = 0;
switch ($_POST['action']) {
    case 'save_data':
        // When action==save_data: verify entered data and save if OK / set errorlevel when NOK
        //
        // Check for data format and required fields
        // change action when not everything is filled-in
        if ($_POST['profiles_name'] == '') {
            $_POST['action'] = 'enter_data';
            $error_level = 1;
            // No profiles_name
        } else {
            // OK, entry can be saved
            $administration_profile = new profile($_POST['profiles_id']);
            $administration_profile->fill($_POST['profiles_name'], $_POST['profiles_rights_login'], $_POST['profiles_rights_projectlisting'], $_POST['profiles_rights_timeregistration'], $_POST['profiles_rights_analysis'], $_POST['profiles_rights_administration']);
            $administration_profile->save();
            // Clear all values except mPath
            foreach ($_POST as $key => $value) {
                if ($key != 'mPath') {
                    unset($_POST[$key]);
                }
            }
        }
        break;
    case 'delete_entry':
        // Check for dependencies
        $administration_profile = new profile($_POST['profiles_id']);
        if ($administration_profile->has_dependencies()) {
            $error_level = 2;
            // Related employee(s) exist