-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
66 lines (58 loc) · 2.88 KB
/
header.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
<?php
// Create a MySQL connection
$servername = "localhost"; // Replace with your server name
$username = "root"; // Replace with your MySQL username
$password = "9586"; // Replace with your MySQL password
$database = "penny_auction"; // Replace with your database name
// Create a connection
$connection = new mysqli($servername, $username, $password, $database);
// Check the connection
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
// Check if the user is logged in
$isLoggedIn = false; // Assuming the user is not logged in initially
// Perform a SQL query to check the user's login status
// Replace 'users' with the actual table name and 'username' and 'password' with the appropriate column names in your database
$query = "SELECT COUNT(*) AS count FROM users WHERE username = 'username_value' AND password = 'password_value'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
if ($row['count'] > 0) {
// The user is logged in
$isLoggedIn = true;
}
?>
<header>
<!-- Import necessary scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.2/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<!-- Import necessary stylesheets -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="/header.css">
<link rel="stylesheet" href="/footer.css">
</header>
<body>
<header>
<div class="container">
<a class="navbar-brand" href="/index.php">Penny Auction Website</a>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<!-- Other header content -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
<?php if (!$isLoggedIn) { ?>
<a class="nav-link" href="login.php">Login</a>
<a class="nav-link" href="signup.php">Signup</a>
<?php } ?>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
<!-- Rest of the header code -->
</body>