Protect certain parts within a page September 8th, 2010, 12:53am
Home Calendar Search Register Login
Welcome, Guest. Please login or register.

FREE Website Scripts ¦ FREE PHP Website Scripts ¦ Website Scripts for free    Downloaded Scripts & Help Tips    AGTC PHP Membership System v1.0 & v1.1  ›  Protect certain parts within a page
Users Browsing Forum
No Members and 1 Guests

 Pages: 1
Recommend Print
  Author    Protect certain parts within a page  (currently 683 views)
gunbad
Posted: February 14th, 2010, 12:43am Report to Moderator
New Member


Posts: 4
Logged On: 37 minutes
I downloaded the script today and found it to be an easy and understandable script that could do the simple thing I wanted it to. I have been spending a few hours now on understanding the different php commands and editing the script to fit my website, fixing bugs etc. and now I am trying to figure out a way to protect certain parts within one page.

Heres the deal: I have a members page (directed to after you log in) where I want a menu of links etc. to appear (links to forums, members only pages, etc.) and within that menu, I want a link to the admin control panel. The problem, however, is that I want the link to the admin control panel to be invisible to level 1 members but visible to level 4 members (admins), on the same one .php page.


Now what I have tried to do is to make a separate file called adminmenu.php and in it I put the following:
<?php include "level4_check_onlyadmins.php"; ?>
<div align="center"><a href="admin.php">Admin Control Panel</a></div>


Then I went to the members index.php page and added the following in the menu:
<?php include "adminmenu.php"; ?>

But what it now does is to include the line;
<?php include "level4_check_onlyadmins.php"; ?>
in the whole index.php page, and not just for the included adminmenu.php page.

This leads to the page being fully visible with the admin control panel in the menu for admin users, but when I log in with a level 1 user the whole page looks destroyed and kind off messed up (because of the php commands messing up).

Am I totally off track here or is there something to it?

Is there a way to protect certain parts of one page from some user levels but still allow higher user levels to see them?

Thanks
Logged Offline
e-mail Private Message
test0mctester
Posted: February 16th, 2010, 1:12pm Report to Moderator
New Member


Posts: 1
Logged On: 24 minutes
You need to establish what level the user is logged in as, and then check for that level.
You can can use $_SESSION, or cookies, or a combination of the two. For my sites (all hobby site, but membership sites non-the-less) I pull the 'user_level' from mysql database, and set a $_SESSION['user_level'], then compare:

(This is over-simplified and sloppy syntax! BEWARE!)

if ($_SESSION['user_level'] < 4)
    {include "member_menu.php";}
    else
    {include "level4_check_onlyadmins.php";}

or the 'inverse' logic:

if ($_SESSION['user_level'] == 4)
    {include "level4_check_onlyadmins.php";}
    else
    {include "member_menu.php";}

I hope this gets you headed in a better direction.....
Logged Offline
e-mail Private Message Reply: 1 - 2
gunbad
Posted: February 16th, 2010, 7:29pm Report to Moderator
New Member


Posts: 4
Logged On: 37 minutes
Sweet! That was actually just what I needed !

Thank you !
Logged Offline
e-mail Private Message Reply: 2 - 2
 Pages: 1
Recommend Print

Locked Board Board Index    AGTC PHP Membership System v1.0 & v1.1  [ previous | next ] Switch to:

Thread Rating
There is currently no rating for this thread
 
Forum Rules
You may not post new threads
You may not post replies
You may not post polls
You may not post attachments
HTML is off
Blah Code is on
Smilies are on

Powered by E-Blah Platinum 9.71B © 2001-2006