Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:43:44+00:00 2026-06-16T09:43:44+00:00

I want to make a certain page viewable only to a certain group of

  • 0

I want to make a certain page viewable only to a certain group of a database. My SQL table is set up as:

Table: DD_users
Columns: id | group | username | paraphrase | guild | level | salt

This is the code I am trying to use:

// First we execute our common code to connection to the database and start the session
require("common.php");

// At the top of the page we check to see whether the user is logged in or not
if(empty($_SESSION['user']))
{
    // If they are not, we redirect them to the login page.
    header("Location: /DD/index.php");

    // Remember that this die statement is absolutely critical.  Without it,
    // people can view your members-only content without logging in.
    die("Redirecting to /DD/index.php");
}

if($_SESSION['user']['group'] == '0')
{
    // Destroy the session to make them log in again.
    unset($_SESSION['user']);

    // If they are not, we redirect them to the login page.
    header("Location: /DD/index.php");

    // Remember that this die statement is absolutely critical.  Without it,
    // people can view your members-only content without logging in.
    die("Redirecting to /DD/index.php");
}

// Everything below this point in the file is secured by the login system

When I try this, will let any user group (0, 1, and 2) access the page when I only want groups 1 and 2 to access the page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:43:45+00:00Added an answer on June 16, 2026 at 9:43 am

    Got it working another way:

    require('common.php');
    $charname = $_SESSION['user']['username'];
    $query = "SELECT adminaccess, guild, username, class, level, active, canRegister, canNews, canActive 
          FROM DD_users 
          WHERE username = ?";
    try
    {
    // These two statements run the query against your database table.
    $stmt = $db->prepare($query);
    $stmt->execute(array($charname));
    }
    catch(PDOException $ex)
    {
    // Note: On a production website, you should not output $ex->getMessage().
    // It may provide an attacker with helpful information about your code. 
    die("Failed to run query: " . $ex->getMessage());
    }
    
    // Finally, we can retrieve all of the found rows into an array using fetchAll
    $rows = $stmt->fetchAll();
    
    //print_r($rows);
    $group = $rows['0']['adminaccess'];
    $guild = $rows['0']['guild'];
    $username = $rows['0']['username'];
    $class = $rows['0']['class'];
    $level = $rows['0']['level'];
    $accessAdmin = $rows['0']['adminaccess'];
    $canRegister = $rows['0']['canRegister'];
    $canNews = $rows['0']['canNews'];
    $canActive = $rows['0']['canActive'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make certain areas of my website accessible to browser users only,
I want to make certain pages of my site available only by https. I
I want to make sure all getters of the classes in a certain package
I want to make a mobile app that makes a user like a certain
I'm trying to dynamically make certain columns readonly at runtime using the following code
How to make a certain buttom be clicked on the load of the page?
I am trying to make an extension as part of which i want certain
I know that on a Facebook fan page, if you want to make a
I want to make a link that when clicked, sends you to a certain
I want to make an administrator page for my website. It will be very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.