-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
50 lines (38 loc) · 1.47 KB
/
Copy pathhome.php
File metadata and controls
50 lines (38 loc) · 1.47 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
<?php
require "database.php";
session_start();
/**< Detect if user loged */
if (!isset($_SESSION["user"])) {
header("Location: login.php");
return;
}
$contacts = $conn->query("SELECT * FROM contacts WHERE user_id = {$_SESSION['user']['id']}");
?>
<?php require "partial/header.php" ?>
<div class="container pt-4 p-3">
<div class="row">
<?php if ($contacts->rowCount() == 0): ?>
<div class="col-md-4 mb-3">
<div class="card text-center">
<div class="card-body">
<p>No contats saved yet</p>
<a href="/contacts-app/add.php">Add one!</a>
</div>
</div>
</div>
<?php endif ?>
<?php foreach($contacts as $contact) : ?>
<div class="col-md-4 mb-3">
<div class="card text-center">
<div class="card-body">
<h3 class="card-title text-capitalize"><?= $contact["name"] ?></h3>
<p class="m-2"><?= $contact["phone_number"] ?></p>
<a href="edit.php?id=<?= $contact["id"]?>" class="btn btn-secondary mb-2">Edit Contact</a>
<a href="delete.php?id=<?= $contact["id"] ?>" class="btn btn-danger mb-2">Delete Contact</a>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
<?php require "partial/footer.php" ?>