...

View Full Version : Show if admin=1



SmoothieVemund
12-05-2010, 08:01 PM
Hello. I'm coding a usersystem. And now I want a navigator witch only administators can see. If you are an administator admin=1 in PHPmyAdmin you will be able to see the links.

Any idea how I can do this?

tropane
12-05-2010, 09:22 PM
if ($admin==1){ echo "blablabla";}

SmoothieVemund
12-06-2010, 02:08 PM
if ($admin==1){ echo "blablabla";}
Thanks. But I have a login system, and I'm having a box only admins should be able to see, so that's what I'm trying to do.

This is my code so far:


<?php
$admin = mysql_query("SELECT admin FROM post WHERE id='$logOptions_id' LIMIT 1");
if (isset($_SESSION['idx'])) {
if ($admin==1){ echo '<div id="title_orange">Staff tools</div>
blablabla'
;};
}
?>

abduraooft
12-06-2010, 02:14 PM
if ($admin==1) You need to fetch the value from the mysql result set using mysql_fetch_row() (http://php.net/mysql_fetch_row) or related.

mfoland
12-06-2010, 08:57 PM
I've seen cookie systems in which the user has a user level.. Example 1 member 2 admin etc... So you could setup a database with Name, password, userlevel and have php grab the data using a cookie for the session.

Then, in the case you have that.. it would be like
if ($userlevel == "2"){?>blah Coding<?}?>

MattF
12-06-2010, 09:04 PM
As abduraooft mentioned, you need to fetch the result of the query:



if (mysql_result($admin, 0))



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum