-
Notifications
You must be signed in to change notification settings - Fork 1
/
excluir.php
38 lines (29 loc) · 914 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
<?php
require __DIR__ . '/vendor/autoload.php';
use \App\Entity\Pergunta;
use \App\Session\Login;
// OBRIGA O USUÁRIO A ESTAR LOGADO
Login::requireLogin();
// VALIDAÇÃO DO ID DA PERGUNTA
if (!isset($_GET['id']) or !is_numeric($_GET['id'])) {
header('location: index.php?status=error');
exit;
}
// CONSULTA A PERGUNTA
$obPergunta = Pergunta::getPergunta($_GET['id']);
// VALIDA SE A PERGUNTA EXISTE
if (!$obPergunta instanceof Pergunta) {
header('location: index.php?status=error');
exit;
}
// Verifica se as informações de `cadastrar.php` foram recebidas com sucesso
if (isset($_POST['excluir'])) {
// Instância a Pergunta
$obPergunta->excluir();
// RETORNA PARA O INDEX
header('location: index.php?status=success');
exit;
}
include __DIR__ . '/includes/header.php';
include __DIR__ . '/includes/confirmar-exclusao.php';
include __DIR__ . '/includes/footer.php';