0% found this document useful (0 votes)
4 views3 pages

Admin Dashboard Access Control Code

Uploaded by

Tanaka
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Admin Dashboard Access Control Code

Uploaded by

Tanaka
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

<?php session_start(); include '[Link]'; if (!

isset($_SESSION['user_id'])) { header('Location:
[Link]?redirect=[Link]'); exit; } $user_id = $_SESSION['user_id']; $result = $conn-
>query("SELECT role, name, email FROM users WHERE id = '$user_id'"); $row = $result->fetch_assoc(); if
($row['role'] != 'admin') { echo "<script>alert('Only admins have access to this section.');</script>";
header('Location: [Link]'); exit; } ?>

<!DOCTYPE html>

<html>

<head>

<title>Admin Dashboard</title>

<link rel="stylesheet" href="[Link]">

<style>

body {

font-family: Arial, sans-serif;

background-color: #f0f0f0;

margin: 0;

padding: 0;

.sidebar {

height: 100vh;

width: 250px;

position: fixed;

top: 0;

left: 0;

background-color: #333;

padding-top: 20px;

.sidebar a {
padding: 10px 15px;

text-decoration: none;

font-size: 18px;

color: #fff;

display: block;

.sidebar a:hover {

background-color: #555;

.main-content {

margin-left: 250px;

padding: 20px;

.avatar {

width: 100px;

height: 100px;

border-radius: 50%;

background-color: #4CAF50;

color: #fff;

font-size: 40px;

text-align: center;

padding-top: 30px;

margin: 20px auto;

.welcome-message {
text-align: center;

font-size: 24px;

margin-bottom: 20px;

</style>

</head>

<body>

<div class="sidebar">

<a href="manage_products.php">Manage Products</a>

<a href="manage_orders.php">Manage Orders</a>

<a href="[Link]">Logout</a>

</div>

<div class="main-content">

<div class="avatar"><?php echo strtoupper(substr($row['email'], 0, 1)); ?></div>

<div class="welcome-message">Welcome, <?php echo $row['name']; ?>!</div>

<h1>Admin Panel</h1>

</div>

</body>

</html>

You might also like