Skip to content

Commit

Permalink
Resolução da issue #442
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielPintoSouza committed Jul 5, 2024
1 parent 6516c85 commit 1606b1f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions dao/adicionar_epi.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<?php
require_once'Conexao.php';
$pdo = Conexao::connect();
$descricao_epi = $_POST["descricao_epi"];
require_once 'Conexao.php';

$descricao_epi = trim($_POST["descricao_epi"]);

$sql = "INSERT into epi(descricao_epi) values('" .$descricao_epi ."')";
$pdo->query($sql);
?>
if (!$descricao_epi || empty($descricao_epi)) {
http_response_code(400);
exit('Erro ao adicionar EPI: A descrição de um EPI não pode ser vazia.');
}

try {
$pdo = Conexao::connect();
$sql = "INSERT into epi(descricao_epi) values(:descricaoEpi)";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':descricaoEpi', $descricao_epi);
$stmt->execute();
} catch (PDOException $e) {
echo 'Erro ao adicionar EPI: '.$e->getMessage();
}

0 comments on commit 1606b1f

Please sign in to comment.