0

hello masters, I have a problem regarding limiting the pages a certain user can access..in my case, i have added a roleID to my members table...
here is the original code first

<h1>Welcome SICS Admin!</h1>
<ul id='adminmenu'>
    <li><a href='index.php'>Modify News Archive</a></li>
    <li><a href='categories.php'>Categories</a></li>
    <li><a href='users.php'>Faculty</a></li>
    <li><a href="../" target="_blank">Department Website</a></li>
    <li><a href='logout.php'>Logout</a></li>
</ul>
<div class='clear'></div>
<hr />

then I went on and made it like this but it doesnt seem to work..I'm a novice in Php so bare with me please..i wanted to remove the Faculty tab for a user whose roleID=2.....

<?php
require_once('../includes/config.php');
if ($row['roleID'] = 1) {
    echo"<h1>Welcome SICS Admin!</h1>
<ul id='adminmenu'>
    <li><a href='index.php'>Modify News Archive</a></li>
    <li><a href='categories.php'>Categories</a></li>
    <li><a href='users.php'>Faculty</a></li>
    <li><a href='./simpleblog/viewpost.php'>Department Website</a></li>
    <li><a href='logout.php'>Logout</a></li>
</ul>
<div class='clear'></div>
<hr />";
}

elseif ($row['roleID'] = 2) {
echo"<h1>Welcome SICS Faculty!</h1>
<ul id='adminmenu'>
    <li><a href='index.php'>Modify News Archive</a></li>
    <li><a href='categories.php'>Categories</a></li>
    <li><a href='./simpleblog/viewpost.php'>Department Website</a></li>
    <li><a href='logout.php'>Logout</a></li>
</ul>
<div class='clear'></div>
<hr />";
}


?>
3
Contributors
8
Replies
47
Views
3 Years
Discussion Span
Last Post by ehpratah
0

oh yea right.forgot.but dude i have a problem look..

<?php
$query = "SELECT roleID FROM blog_members where roleID="roleID of the currently logged in user";
if ($row['roleID'] = 1) {
    echo"<h1>Welcome SICS Admin!</h1>
<ul id='adminmenu'>
    <li><a href='index.php'>Modify News Archive</a></li>
    <li><a href='categories.php'>Categories</a></li>
    <li><a href='users.php'>Faculty</a></li>
    <li><a href='./simpleblog/viewpost.php'>Department Website</a></li>
    <li><a href='logout.php'>Logout</a></li>
</ul>
<div class='clear'></div>
<hr />";
}
elseif ($row['roleID'] = 2) {
    echo"<h1>Welcome SICS Faculty!</h1>
<ul id='adminmenu'>
    <li><a href='index.php'>Modify News Archive</a></li>
    <li><a href='categories.php'>Categories</a></li>
    <li><a href='./simpleblog/viewpost.php'>Department Website</a></li>
    <li><a href='logout.php'>Logout</a></li>
</ul>
<div class='clear'></div>
<hr />";
}

Edited by RonKevinT.Manuela: wrong

0

are you using any session variable for : roleID of the currently logged in user in select query.

0

i think not....i just added roleid to my members table and was hoping to remove faculty tab when roleid of the logged in user is '2'...

0

then use This select Query.

$query = "SELECT roleID FROM blog_members where roleID='2'";
0

i take back what I just said..lol..clearly Im lost...let us put it in this way how about a query that selects the roleid of the currently logged in user?...

0

you are assigning a number when you use = only. try Using == iN yOUr if statement not = like $row['roleID'] == 1

Edited by ehpratah: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.