/
index.php
60 lines (59 loc) · 1.56 KB
/
index.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
<?php
require_once 'classes/User.php';
$user = new User();
include_once('partials/delete.php');
?>
<!DOCTYPE HTML>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CRUD PHP</title>
<link rel="stylesheet" href="assets/css/bootstrap.css">
</head>
<body>
<div class="container">
<header class="masthead">
<h1 class="muted">CRUD PHP</h1>
</header>
<?php
include_once('partials/new.php');
include_once('partials/edit.php');
?>
<?=$messageDelete?>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Nome:</th>
<th>E-mail:</th>
<th>Ações:</th>
</tr>
</thead>
<?php foreach($user->findAll() as $key => $value): ?>
<tbody>
<tr>
<td><?php echo $value->id; ?></td>
<td><?php echo $value->name; ?></td>
<td><?php echo $value->email; ?></td>
<td>
<a href="index.php?action=edit&id=<?=$value->id?>">Editar</a>
<a class="js-button-delete" href="index.php?action=delete&id=<?=$value->id?>">Deletar</a>
</td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</div>
<script type="text/javascript">
var deleteLink = document.querySelectorAll('.js-button-delete');
for (var i = 0, len = deleteLink.length; i < len; i++) {
deleteLink[i].addEventListener('click', function(event) {
if (!confirm("Deseja realmente deletar?")) {
event.preventDefault();
}
});
}
</script>
</body>
</html>