<?php require_once './cabecalho.php'; ?> <h1>Bem vindo!</h1> <?php if (isLogado()) { sucesso("Você está logado como " . getUsuarioLogado()); echo '<a href="logout.php">logout</a>'; } else { ?> <h2>Login</h2> <form action="login.php" method="POST"> <table class="table"> <tr> <td><label for="txtEmail">Email</label></td> <td><input class="form-control" type="text" name="email" id="txtEmail" value="" /></td> </tr> <tr> <td><label for="txtSenha">Senha</label></td> <td><input class="form-control" type="password" name="senha" id="txtSenha" value="" /></td> </tr> <tr> <td colspan="2"><center><input class="btn btn-primary" type="submit" value="Login" /></center></td> </tr> </table> </form> <?php
<?php require_once "cabecalho.php"; require_once "ProdutoDAO.php"; verificaAutenticacao(); $id = filter_input(INPUT_POST, "id"); $nome = filter_input(INPUT_POST, "nome"); $preco = filter_input(INPUT_POST, "preco"); $checked = filter_input(INPUT_POST, "usado"); $categoria = filter_input(INPUT_POST, "categoria"); if ($checked) { $checked = "true"; } else { $checked = "false"; } if (alteraProduto($connection, $nome, $preco, $checked, $categoria, $id)) { mysqli_close($connection); sucesso("Produto atualizado com sucesso!"); } else { $error = mysqli_error($connection); mysqli_close($connection); falha("Não foi possível alterar o produto: " . $error); } include 'rodape.php';
<?php require_once "cabecalho.php"; require_once "ProdutoDAO.php"; verificaAutenticacao(); $nome = filter_input(INPUT_POST, "nome"); $preco = filter_input(INPUT_POST, "preco"); $checked = filter_input(INPUT_POST, "usado"); $categoria = filter_input(INPUT_POST, "categoria"); if ($checked) { $checked = "true"; } else { $checked = "false"; } if (adicionaProduto($connection, $nome, $preco, $checked, $categoria)) { mysqli_close($connection); sucesso("O produto " . $nome . " que custa " . $preco . " foi adicionado com sucesso!"); } else { $error = mysqli_error($connection); mysqli_close($connection); falha("Não foi possível cadastrar o produto: " + $error); } include 'rodape.php';