-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
70 lines (41 loc) · 1.48 KB
/
delete.php
File metadata and controls
70 lines (41 loc) · 1.48 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once("config/db.php");
$id = 0;
if(!empty($_GET['id'])) {
$id = $_REQUEST['id'];
}
if(!empty($_POST)) {
$id = $_POST['id'];
$pdo = connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "DELETE FROM contatos where id = ?";
$q = $pdo->prepare($sql);
$q->execute(array($id));
disconnect();
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style/css/bootstrap.min.css">
<title>CRUD | PHP</title>
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div class="container">
<div class="row justify-content-center mt-5">
<h3>Excluir Contato</h3>
</div>
<div class="row justify-content-center mt-3">
<form action="delete.php" method="post">
<input type="hidden" name="id" value="<?php echo $id;?>"/>
<p>Deseja realmente excluir este contato?</p>
<button class="btn btn-dark mt-3 mb-3" type="submit">Deletar</button>
<a class="btn text-dark mt-3 mb-3 ml-2" href="index.php" type="btn">Cancelar</a>
</form>
</div>
</div>
</body>
</html>