Jump to content

Display page based on rank status


gnetuk
Go to solution Solved by Ch0cu3r,

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
Share on other sites

  • Solution

 

 

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.