How to develop Projects Using PHP and Mysql -Part 6

Rashmi Mishra
0



How to develop Projects Using PHP and Mysql 

Part 6

user_dashboard and admin_dashboard page ( after using bootstrap)

1. user_dashboard.php

<?php

session_start();

 

// Check if user is logged in

if (!isset($_SESSION['user_id'])) {

    header("Location: login.php");

    exit();

}

 

// Retrieve user information

$user_name = $_SESSION['user_name'];

$user_email = $_SESSION['user_email'];

?>

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>User Dashboard</title>

    <link rel="stylesheet" href="../assets/css/style.css">

</head>

<body>

 

<?php include '../includes/header.php'; ?>

<div class="main-wrapper">

    <?php include '../includes/sidebar.php'; ?>

 

    <div class="container">

    <div class="row">

       

        <h2>Welcome, <?php echo htmlspecialchars($user_name); ?>!</h2><br>

        <p>Email: <?php echo htmlspecialchars($user_email); ?></p><br>

       

        <p>This is your user dashboard. You can manage your profile and perform other user-specific tasks.</p>

</div>

    </div>

</div>

 

<?php include '../includes/footer.php'; ?>

 

</body>

</html>

 


assets/css/style.css 
style.css

body {

    font-family: Arial, sans-serif;

    background-color: #f8f9fa;

    margin: 0;

    padding: 0;

    display: flex;

    flex-direction: column;

    min-height: 100vh;

}

 

.container {

    flex-grow: 1; /* Push footer to the bottom */

    display: flex;

    justify-content: center;

    align-items: center;

    height: calc(100vh - 120px); /* Adjust height between navbar & footer */

    padding: 20px;

}

 

.login-box {

    background: white;

    padding: 30px;

    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);

    border-radius: 8px;

    width: 100%;

    max-width: 400px;

    text-align: center;

}

 

h2 {

    margin-bottom: 20px;

    color: #333;

}

 

.error {

    color: red;

    margin-bottom: 15px;

}

 

form {

    display: flex;

    flex-direction: column;

}

 

label {

    text-align: left;

    font-weight: bold;

    margin: 10px 0 5px;

}

 

input {

    padding: 10px;

    border: 1px solid #ccc;

    border-radius: 5px;

    width: 100%;

}

 

button {

    background: #007bff;

    color: white;

    border: none;

    padding: 10px;

    border-radius: 5px;

    cursor: pointer;

    margin-top: 15px;

    font-size: 16px;

}

 

button:hover {

    background: #0056b3;

}

 

p {

    margin-top: 10px;

}

 

a {

    color: #007bff;

    text-decoration: none;

}

 

a:hover {

    text-decoration: underline;

}



/* General Styles */

body {

    font-family: Arial, sans-serif;

    background: #f4f4f4;

    margin: 0;

    padding: 0;

}

 

/* Wrapper to hold sidebar + content */

.main-wrapper {

    display: flex;

    min-height: 100vh;

}

 

/* Sidebar Styles */

.sidebar {

    width: 250px;

    height: 100vh;

    background-color: #2C3E50;

    color: white;

    padding-top: 20px;

    position: fixed;

    left: 0;

    top: 0;

    transition: 0.3s;

    z-index: 1000;

}

 

.sidebar-header {

    text-align: center;

    padding: 15px;

    font-size: 20px;

    background-color: #1ABC9C;

    color: white;

}

 

.sidebar-menu {

    list-style: none;

    padding: 0;

    margin: 0;

}

 

.sidebar-menu li {

    padding: 15px 20px;

}

 

.sidebar-menu a {

    color: white;

    text-decoration: none;

    display: block;

    transition: 0.3s;

}

 

.sidebar-menu a:hover {

    background-color: #1ABC9C;

    border-radius: 5px;

}

 

/* Logout Button */

.logout-btn {

    display: inline-block;

    padding: 10px 20px;

    background: #E74C3C;

    color: white;

    text-decoration: none;

    border-radius: 5px;

    transition: 0.3s;

}

 

.logout-btn:hover {

    background: #C0392B;

}

 

/* Main Content */

.container {

    margin-left: 250px; /* Sidebar width */

    padding: 20px;

    transition: margin-left 0.3s;

    flex: 1;

}

 

/* Sidebar Collapsed */

.collapsed {

    width: 60px;

}

 

.collapsed + .container {

    margin-left: 60px;

}

 

/* Responsive Design */

@media (max-width: 768px) {

    .sidebar {

        width: 60px;

    }

 

    .container {

        margin-left: 60px;

    }

}

 

 


Post a Comment

0Comments

Post a Comment (0)