-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
68 lines (67 loc) · 2.49 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
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<h3>Crud Php Pdo + Login</h3>
</div>
<?php
require 'Database.php';
require 'Auth.php';
$pdo = Database::connect();
$auth = new Auth($pdo);
?>
<div class="<?= $auth->isLoggedIn() ? "loggedIn" : "loggedOut"; ?>">
<?php
require 'loginForm.php'
?>
</div>
<?php
if($auth->isLoggedIn()) {
?>
<div class="row">
<p align="right">
<a href="?logout" class="btn btn-info">Logout</a>
</p>
<p>
<a href="create.php" class="btn btn-success">Create User</a>
</p>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Password</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = 'SELECT * FROM user ORDER BY id DESC';
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
echo '<td>'. $row['username'] . '</td>';
echo '<td>'. $row['password'] . '</td>';
echo '<td width=250>';
echo '<a class="btn" href="read.php?id='.$row['id'].'">Read</a>';
echo ' ';
echo '<a class="btn btn-success" href="update.php?id='.$row['id'].'">Update</a>';
echo ' ';
echo '<a class="btn btn-danger" href="delete.php?id='.$row['id'].'">Delete</a>';
echo '</td>';
echo '</tr>';
}
Database::disconnect();
?>
</tbody>
</table>
</div>
<?php } ?>
</div>
</body>
</html>