Jump to content
Sign in to follow this  
Max21

Login user leven

Recommended Posts

Hello,

I am Max and new here. sorry for the spelling but my English is not so good.

I create a website in php.

after logging in I will go to the "Home.pgp".

 

Now I do not want to show all navagation buttons for certain level users on the home page.

how can I do this best?

have already tried everything but do not get out of it.

 

I have a sql database with username, password and level (admin / user / service)

this is my code from the home page in which I enter the username of the login

call :

 

 

<?php

 

// Include config file

require_once 'config.php';

 

// Initialize the session

session_start();

 

 

// If session variable is not set it will redirect to login page

if(!isset($_SESSION['gebruikersnaam']) || empty($_SESSION['gebruikersnaam'])){

header("location: Index.php");

exit;

}

 

?>

  

 

<!DOCTYPE html>

<html>

  

<title>Mack Projects @ Techniek</title>

  

 

<meta charset="UTF-8">

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

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="Css/Index.css">

<style>

  

 

 

html,body,h1,h2,h3,h4,h5 {font-family: "Raleway", sans-serif}

</style>

<body class="w3-light-grey">

  

 

<!-- Top container -->

<div class="w3-bar w3-top w3-black w3-large" style="z-index:4">

<button class="w3-bar-item w3-button w3-hide-large w3-hover-none w3-hover-text-light-grey" onclick="w3_open();"><i class="fa fa-bars"></i> Menu</button>

<span class="w3-bar-item w3-left"><img src="Afbeeldingen/Index/Techniek_Poppetje_Home.jpg"> </span>

<span class="w3-bar-item w3-right">Mack Projects @ Techniek</span>

</div>

 

  

 

<!-- Sidebar/menu -->

<nav class="w3-sidebar w3-collapse w3-white w3-animate-left" style="z-index:3;width:300px;" id="mySidebar"><br>

<div class="w3-container w3-row">

<div class="w3-col s4">

<img src="/w3images/avatar2.png" class="w3-circle w3-margin-right" style="width:46px">

</div>

<div class="w3-col s8 w3-bar">

  

<span><br><br>

Welkom <b><?php echo htmlspecialchars($_SESSION['gebruikersnaam']); ?></b></span><br>

  

<a href="#" class="w3-bar-item w3-button"><i class="fa fa-envelope"></i></a>

<a href="#" class="w3-bar-item w3-button"><i class="fa fa-user"></i></a>

<a href="#" class="w3-bar-item w3-button"><i class="fa fa-cog"></i></a>

</div>

</div>

<hr>

  

 

 

 

<div class="w3-container">

<h5>Dashboard</h5>

</div>

 

  

<div class="w3-bar-block">   

<a href="#" class="w3-bar-item w3-button w3-padding-16 w3-hide-large w3-dark-grey w3-hover-black" onclick="w3_close()" title="close menu"><i class="fa fa-remove fa-fw"></i> Close Menu</a>

<a href="#" class="w3-bar-item w3-button w3-padding w3-blue"><i class="fa fa-users fa-fw"></i> Overview</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-eye fa-fw"></i> Views</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-users fa-fw"></i> Traffic</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-bullseye fa-fw"></i> Nieuws</a>

 

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-diamond fa-fw"></i> ToDo</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-bell fa-fw"></i> Agenda</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-bank fa-fw"></i> Magazijn</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-history fa-fw"></i> Zone's</a>

<a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-cog fa-fw"></i> Instellingen</a><br><br>

</div>

 

 

I want to thank you for the help!

this is something purely as a hobby and not commercial that I do this

Share this post


Link to post
Share on other sites

Store whatever information you need to know about a user in the session, and when you're printing the navigation bar check the values in the session to see if you should print each item.

Share this post


Link to post
Share on other sites

I don't know, I don't know what you have in your database and specifically what you want to achieve.

Store the user level in the session when someone logs in.  I assume you have some way to get the user level from the database or otherwise determine what level a user is.

When you're printing the HTML for the nav menu, use PHP to check the user level that you saved in the session to determine whether or not you want to show that HTML.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×