add this to git finally
This commit is contained in:
40
header.php
Normal file
40
header.php
Normal file
@ -0,0 +1,40 @@
|
||||
<header>
|
||||
<nav class="nav-links">
|
||||
<a href="/users">Users</a>
|
||||
<a href="/products">Products</a>
|
||||
<a href="/orders">Orders</a>
|
||||
</nav>
|
||||
|
||||
<div class="auth-section">
|
||||
<?php
|
||||
session_start(); if(isset($_SESSION['username']) && !empty($_SESSION['username'])): ?>
|
||||
<div class="user-info">
|
||||
<span class="username">Welcome, <?=htmlspecialchars($_SESSION['username'])?></span>
|
||||
<a href="/logout" class="logout-link">Log out</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if (isset($_SESSION['error_message'])): ?>
|
||||
<p style="color: red; text-align: center;"><?= $_SESSION['error_message'] ?></p>
|
||||
<?php endif; ?>
|
||||
<form id="authenticate-form" action="/login" method="post">
|
||||
<input type="text" name="username" placeholder="Username (*for registration*)">
|
||||
<input type="text" name="email" placeholder="Email" required>
|
||||
<input type="password" name="password" placeholder="Password" required>
|
||||
<button type="button" onclick="submitForm('login');">Login</button>
|
||||
<button type="button" class="register-btn" onclick="submitForm('register');">Register</button>
|
||||
</form>
|
||||
<script>
|
||||
function submitForm(action) {
|
||||
const form = document.getElementById('authenticate-form');
|
||||
|
||||
form.action = `/${action}`;
|
||||
if (form.checkValidity()) {
|
||||
form.submit();
|
||||
} else {
|
||||
form.reportValidity();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
Reference in New Issue
Block a user