-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
42 lines (35 loc) · 1.14 KB
/
home.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
<?php
require "database.php";
session_start();
if (!isset($_SESSION["user"])) {
header("Location: login.php");
return;
}
$contacts = $conn->query("SELECT * FROM contacts WHERE user_id = {$_SESSION['user']['id']}");
?>
<?php require "partials/header.php"; ?>
<div class="container pt-4 p-3">
<div class="row">
<?php if ($contacts->rowCount() == 0): ?>
<div class="col-md-4 mx-auto">
<div class="card card-body text-center">
<p>No contacts saved yet</p>
<a href="add.php">Add One!</a>
</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 "partials/footer.php"; ?>