From 1606b1f6223c5353a45e89656b8e2e9709038801 Mon Sep 17 00:00:00 2001 From: GabrielPintoSouza Date: Fri, 5 Jul 2024 07:45:13 -0300 Subject: [PATCH] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20da=20issue=20#442?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/adicionar_epi.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dao/adicionar_epi.php b/dao/adicionar_epi.php index 6072c76e..19e66a0c 100755 --- a/dao/adicionar_epi.php +++ b/dao/adicionar_epi.php @@ -1,8 +1,19 @@ query($sql); -?> \ No newline at end of file +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(); +}