-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexcluir.php
40 lines (29 loc) · 885 Bytes
/
excluir.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
session_start();
require __DIR__.'/vendor/autoload.php';
use App\Helpers\Session;
use App\Entity\Produto;
use App\Helpers\Validate;
$session = new Session();
$validate = new Validate();
/** Validação do ID */
if (!isset($_POST['id']) OR !is_numeric($_POST['id'])) {
header('Location: index.php?status=error');
exit;
}
/** Consultar Produto */
$obProduto = Produto::getProduto($_POST['id']);
/** Validação se Produto existe */
if (!$obProduto instanceof Produto) {
header('Location: index.php?status=error');
exit;
}
if (isset($_POST['excluir'])) {
if ($obProduto->excluir()) {
$session->flash('message', 'Produto excluido com sucesso.');
$session->flash('type', 'success');
header('Location: index.php'); exit;
}
$session->flash('message', 'Erro ao excluir produto.');
header('Location: index.php'); exit;
}