예제 #1
0
<?php

require_once "../Engine/CategoriasClass.php";
$categorias = new Categorias();
echo "Teste ADICIONAR CATEGORIA<br>";
$res = $categorias->AdicionaCategoria("Imagens", "C:\\Users\\Jorge\\Documents\\Projetos\\Biblioteca Virtual\\Imagens_categorias\\imagem.png");
if ($res == TRUE) {
    echo "Categoria adicionada!";
}
echo "<br><br>";
echo "Teste CARREGA CATEGORIAS<br>";
$result = $categorias->CarregaCategorias();
if (isset($result)) {
    $n = count($result);
    for ($i = 0; $i < $n; $i++) {
        echo "ID: " . $result[$i]["id"] . "<br>";
        echo "NOME: " . $result[$i]["nome"] . "<br>";
    }
}
echo "<br><br>";
echo "Teste REMOVE CATEGORIA<br>";
$res = $categorias->RemoveCategoria($result[$n - 1]["id"]);
if ($res == TRUE) {
    echo "Categoria Removida!";
}
예제 #2
0
function CadastraCategoria()
{
    $erro = array();
    foreach ($_POST as $chv => $vlr) {
        if ($vlr == "" && substr($chv, 0, 3) == "USR") {
            $erro[] = "O campo " . substr($chv, 4) . " não foi informado";
        }
    }
    $n = count($erro);
    if ($n > 0) {
        header("location: ../categorias.php?status=error");
        return;
    }
    $cat = new Categorias();
    $_nome = $_POST['CAT_NOME'];
    $_file = $_FILES['CAT_FILE'];
    if ($_file["error"] > 0) {
        header("location: ../categorias.php?status=error");
        return;
    }
    $_imagem = Arquivos::UpdateArquivo("../" . $_SESSION['categoriasImagePrefix'], $_file);
    $result = $cat->AdicionaCategoria($_nome, $_imagem);
    if ($result == TRUE) {
        header("location: ../categorias.php?status=success");
    } else {
        header("location: ../categorias.php?status=error");
    }
    return;
}