-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeletar.php
More file actions
51 lines (35 loc) · 1.13 KB
/
deletar.php
File metadata and controls
51 lines (35 loc) · 1.13 KB
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
<!-- QUESTÃO 03 --
Crie uma página que com um ‘id’ recebido por GET, apague um registro do banco, apresentando uma mensagem de sucesso ou um erro caso não consiga excluir.
-->
<!DOCTYPE html>
<html>
<head>
<title>DELETE | deletar</title>
</head>
<body>
<?php
//Esses dois nao falo mais
require 'db.php';
$conn = conectar_banco();
//Pegando o id via GET
$id = $_GET['id'];
$stmt = $conn->prepare("DELETE FROM contatos WHERE id = :id");
$stmt->bindParam(':id', $id);
$stmt->execute();
$linhas_deletadas = $stmt->rowCount();
?>
<?php if ($linhas_deletadas < 1): ?>
<center>
<h1>Erro durante o delete</h1>
<br><br>
<a href="index.php">Voltar</a>
</center>
<?php else: ?>
<center>
<h1>Registro deletado com sucesso</h1>
<br><br>
<a href="index.php">Voltar</a>
</center>
<?php endif ?>
</body>
</html>