Privileges of users(2)

Asked

Viewed 50 times

-1

Well, I’m on a college exercise that’s creating a blog. Can contain 4 different users: User(only reads post and comments) Redator(Creates posts and manages comments) ADM(manages all posts and comments) ADM General total system control (create, edit.delete any element including users and permissions)

To create post, change permissions etc, you need a navigation bar on the site, my question is: How can I make appear the corresponding options in the bar for each user?

Each user has a corresponding number: the user = 1 , redactor = 2... This code below is from my login, I would like to make the privilege at this time,when the user logs in,he goes to the main page and will have the options that correspond to his level. Also, the navigation bar, button style, div’s, must be in a separate file.

<?php
session_start();
$_SESSION["new"]="limitado";
require_once('BdClass.php');
if(isset($_GET['login']) and isset($_GET['senha'])){
$objBd = new bd();
$objBd->conecta_mysql();
$param= array();
array_push($param, $_GET['login']);
array_push($param, $_GET['senha']);
$sql="SELECT nome,senha,id,tipo from usuario where nome=? and senha=? and ativo = 1;";
$result=$objBd->exec($sql,'ss',$param);
$valor=mysqli_fetch_array($result);
if(isset($valor['nome'])){
    $_SESSION["nome"]=$valor['nome'];
    $_SESSION["senha"]=$valor['senha'];
    $_SESSION["id"]=$valor['id'];
    $_SESSION["tipo"]=$valor['tipo'];
    $_SESSION["ativo"] = 1;
    header("location:1.html");
}
else{
     echo "<script>alert('Se cadastre antes para logar no site');</script>";
 }
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="estilo.css">
    <title>INICIO</title>
</head>
<body>
<ul>
  <li><a href="Pagi.php">Oh...Blooog!</a></li>
  <<li><a href="Login.php">Cadastro</a></li>
</ul>
<form method="GET" action="Login.php">
    <label>Nome: </label>
    <div><input type="text" name="login" value="">
    </div>
    <label>Senha: </label>
    <div><input type="password" name="senha">
    </div>
    <div><input type="submit" name="ok">
    </div>
</form>
</body>
</html>
  • Doubled because?

  • If your doubt is an unfolding of the previous one, put the link of the previous one quoting it and put here only the relevant differential points

1 answer

1


Creates a switch structure, and saves in an array all functions of each user permission at the end of the switch creates a foreach of each user permission

  • In which part of this code?

  • the best place would be to check and put inside the array of functions at the top of the page (after the query), and to do the foreach would be where you want to put the inputs, links, etc., as it will give an echo of each user function

Browser other questions tagged

You are not signed in. Login or sign up in order to post.