Skip to content

Commit c8923de

Browse files
Abstraced the logged in header into a template file and included it on the index and page pages.
1 parent f3d3ab0 commit c8923de

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

header.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="container">
2+
<header class="d-flex flex-wrap py-3 mb-4 border-bottom">
3+
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
4+
<span class="fs-4">Authentication Example</span>
5+
</a>
6+
7+
<ul class="nav nav-pills">
8+
<li class="nav-item"><a href=/logout.php#" class="nav-link">Log out</a></li>
9+
</ul>
10+
</header>
11+
</div>

web/index.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
1818
</head>
1919
<body>
20-
<div class="container">
21-
<header class="d-flex flex-wrap py-3 mb-4 border-bottom">
22-
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
23-
<span class="fs-4">Authentication Example</span>
24-
</a>
25-
26-
<ul class="nav nav-pills">
27-
<li class="nav-item"><a href=/logout.php#" class="nav-link">Log out</a></li>
28-
</ul>
29-
</header>
30-
</div>
20+
<?php include '../header.php'; ?>
3121

3222
<div class="container">
3323
<h1>Homepage</h1>
34-
<p>Welcome <?php echo $_SESSION['name']; ?></p>
24+
<p>Welcome <?php echo htmlspecialchars($_SESSION['name']); ?></p>
3525
<p><a href="/page.php">Visit inner page.</a></p>
3626
</div>
3727
</body>

web/page.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,8 @@
1717
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
1818
</head>
1919
<body>
20-
<div class="container">
21-
<header class="d-flex flex-wrap py-3 mb-4 border-bottom">
22-
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
23-
<span class="fs-4">Authentication Example</span>
24-
</a>
20+
<?php include '../header.php'; ?>
2521

26-
<ul class="nav nav-pills">
27-
<li class="nav-item"><a href=/logout.php#" class="nav-link">Log out</a></li>
28-
</ul>
29-
</header>
30-
</div>
3122
<div class="container">
3223
<h1>Inner Page</h1>
3324
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac quam sit amet neque maximus dictum.</p>

0 commit comments

Comments
 (0)