Пример #1
0
<html>
	<head>
		<title>Cadastro de Editora</title>
	</head>
	<body>
		
	
		<h1>Cadastro de Editora</h1>
		
		<?php 
$editora = new Editora();
$editoras = new ColecaoDeEditorasEmBDR($pdo);
if (isset($_GET['id'])) {
    $id = htmlspecialchars(trim($_GET['id']));
    try {
        $editora = $editoras->comId($id);
    } catch (ColecaoException $e) {
        echo 'Erro ao obter os dados: ' . $e->getMessage();
    }
} else {
    if (isset($_POST['enviar'])) {
        if (isset($_POST['nome']) and isset($_POST['id'])) {
            $nome = htmlspecialchars(trim($_POST['nome']));
            $id = htmlspecialchars(trim($_POST['id']));
            $editora = new Editora($id, $nome);
            if ($id > 0) {
                try {
                    $editoras->atualizar($editora);
                } catch (ColecaoException $e) {
                    echo 'Erro ao atualizar os dados: ' . $e->getMessage();
                }
Пример #2
0
    $id = htmlspecialchars(trim($_GET['id']));
    try {
        $revista = $revistaBDR->comId($id);
        echo $revista->nome();
    } 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');