if (USER_ID !== $question->uid && !$session->adminCheck()) { die(json_encode(['status' => false, 'id' => $PostID, 'err' => 'Authentication error.'])); } $errors = []; $QNA = new QNA($PostID); if ($title != $question->title) { if (trim($title) == '') { die(json_encode(['err' => 'Title can\'t be empty'])); } $edit = $QNA->edit_title($title); if ($edit !== true) { $errors[] = $edit; } } if ($content != $question->content) { $edit = $QNA->edit_question($content); if ($edit !== true) { $errors[] = $edit; } } if (empty($errors)) { die(json_encode(['status' => true])); } else { die(json_encode(['err' => $errors])); } break; case 'save': $PostID = sanitize_id($data['id']); $QNA = new QNA($PostID); // check if question exists $question = $QNA->get_question();