Jump to content

Display page based on rank status


gnetuk

Recommended Posts

Hello all good day.
 
I am working on my new project atm, and it requires that registerd users will have rank status, 0 , 1 , 2 , 3 , 4 4=SUPER ADMIN
 
ok i need so that anyone less than rank 3 can use the registration form.
 
I cant provode my code as my www is on local host and im away from that pc atm.
 
so in a nut shell
 
SELECT rank from users where name = SESSION_['user']
 
IF rank = < 3
 
die (you dont have privlage)
 
Hope you guys can help
 
g-

Link to comment
https://forums.phpfreaks.com/topic/286888-display-page-based-on-rank-status/
Share on other sites

 

 

so in a nut shell

 

SELECT rank from users where name = SESSION_['user']

 

IF rank = < 3

 

die (you dont have privlage)

The psuedo code your posted would be the correct logic, which converted into PHP code would look somthing like

<?php
session_start(); // resume session

$mysqli = new mysqli('localhost', 'user', 'pass', 'database'); // connect to mysql db

$stmt = $mysqli->prepare('SELECT rank from users where name = ?'); // the query
$stml->bind_param('s', $_SESSION['user']); // pass the user stored in session to the query
 
$stmt->execute(); // execute query
$stmt->bind_result($user_rank); // store the value of the rank column returned from the query iuto $user_rank variable
$stmt->close();

// check the users rank
if($user_rank < 3)
  die('Sorry you do not have the correct privilages to view this page'); // kill page, display error

// display reset of page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.