} catch (ColecaoException $e) { echo 'Erro ao obter os dados: ' . $e->getMessage(); } } else { if (isset($_POST['enviar'])) { if (isset($_POST['id']) and isset($_POST['nome']) and isset($_POST['mes']) and isset($_POST['ano']) and isset($_POST['editora'])) { $id = htmlspecialchars(trim($_POST['id'])); $nome = htmlspecialchars(trim($_POST['nome'])); $mes = htmlspecialchars(trim($_POST['mes'])); $ano = htmlspecialchars(trim($_POST['ano'])); $IdEditora = htmlspecialchars(trim($_POST['editora'])); $editora = $editoraBDR->comId($IdEditora); $revista = new Revista($id, $nome, $mes, $ano, $editora); if ($id > 0) { try { $revistaBDR->atualizar($revista); } catch (ColecaoException $e) { echo 'Erro ao atualizar os dados: ' . $e->getMessage(); } } else { try { $revistaBDR->adicionar($revista); } catch (ColecaoException $e) { echo 'Erro ao adicionar os dados: ' . $e->getMessage(); } } header('Location: revista-lista.php'); } } } ?>