-
Notifications
You must be signed in to change notification settings - Fork 0
/
animalDelete.php
109 lines (63 loc) · 3.72 KB
/
animalDelete.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
require_once('settings/check.php');
require_once('class/Login.php');
if (isset($_GET['cod'])) {
$_SESSION['codAnimal'] = trim(strip_tags(htmlspecialchars($_GET['cod'])));
} else {
header('Location: profile.php');
}
?>
<!DOCTYPE html>
<html lang="PT-BR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>MiauCãoce se Puder</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/estilo.css" />
<link rel="stylesheet" type="text/css" href="css/delete.css" />
<link rel="icon" href="images/logomarcaPreta.png" type="image/x-icon" />
</head>
<body>
<div class="main-content">
<div class="secondary-content">
<div class="title-box">
<?php
if (isset($_POST['no-choice'])) {
header('Location: profile.php');
} elseif (isset($_POST['yes-choice'])) {
try {
$animalDelete = new Login();
$selectSentence = 'SELECT cod_anuncio FROM anuncio, animal WHERE cod_anuncio = animal_cod_anuncio AND cod_animal = :codAnimal';
$selectData = $connection -> prepare($selectSentence);
$codAnimal = $_SESSION['codAnimal'];
$selectData -> bindParam(':codAnimal', $codAnimal);
$selectData -> execute();
while ($row = $selectData -> fetch(PDO::FETCH_ASSOC)) {
extract($row);
$sentenceOfDelete = 'DELETE FROM anuncio WHERE cod_anuncio = :codAnuncio';
$deleteData = $connection -> prepare($sentenceOfDelete);
$deleteData -> bindParam(':codAnuncio', $cod_anuncio);
if ($deleteData -> execute()) {
$_SESSION['codAnimal'] = null;
header('Location: profile.php');
} else {
print "<h1 id='error-message'>" . 'Ocorreu um erro, tente novamente mais tarde.' . "</h1>";
}
}
} catch (PDOException $error) {
print 'Conexão falhou!' . $error -> getMessage();
}
}
?>
<h1>Tem certeza que deseja excluir o anúncio?</h1>
</div>
<form method="POST" action=<?php print $_SERVER['PHP_SELF']; ?> class="form-box">
<input type="submit" name="no-choice" value="Não" class="form-submit-input" id="no-submit" />
<input type="submit" name="yes-choice" value="Sim" class="form-submit-input" id="yes-submit" />
</form>
</div>
</div>
</body>
</html>