ronnie88 Posted July 25, 2008 Share Posted July 25, 2008 I'm trying to add a admin mod on a php login it uses the session how would i do something like this?: if(isset($_SESSION['username']) == admin is admin } so if the mysql column admin has admin in it... it will show the text Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bump..... Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 what? your question doesnt make any sense Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 i'm trying to make if a column in the mysql table says admin it will show extra capablities Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 ok then add one in PHP my admin or ure database managment program Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 yea, but how would i go about developing the if session code... is equal to the username and so and so admin column..? i tried this [code] if($row['admin']== 'admin'){ echo "test1"; } and added admin to the admin column and the top of the page if(isset($_SESSION['username']) && !empty($_SESSION['username'])) { $query = "SELECT va, cash, forum, admin FROM virtuala WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); } ?> but no luck[/code] Quote Link to comment Share on other sites More sharing options...
tibberous Posted July 25, 2008 Share Posted July 25, 2008 Are you neglecting to call session start? More importantly, don't say isset($_SESSION['username']) && !empty($_SESSION['username']), just say, if($_SESSION['username']) - their not even 100% equivalent, the latter way is better and a lot less to type / read. Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 no session is started Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 i tried using a variable such as: <?session_start(); include("database.php"); if($_SESSION['username']) { $query = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); } $admin = $row['admin']; ?> if($admin == 'admin'){ echo "test1"; } else{ echo "help me"; } ?> but still no luck.. and tried using a mysql error no errors.. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 this is wrong <?session_start(); include("database.php"); if($_SESSION['username']) { $query = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); } $admin = $row['admin']; ?> it should be , short tag should not be used <?php session_start(); include("database.php"); if($_SESSION['username']) { $query = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); } $admin = $row['admin']; ?> Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 still no luckall it does is just keeps putting out the else if i echo the $admin it does say admin Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 i've tried this now too <?php session_start(); include("database.php"); if($_SESSION['username']) { $query = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); } $admin = "{$row['admin']}"; ?> <?php if($admin == 'admin'){ echo "test1"; } else{ echo "help me"; } ?> but no luck Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted July 25, 2008 Share Posted July 25, 2008 where you are fetching the result? $result = mysql_query($query); $row = mysql_fetch_row($result); } $admin = "{$row['admin']}"; Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 if i put that in there it messes up the whole script, but it should be working since I tried echoing the row admin and it outputs what I have in there. Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bump Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 i've also tried this now: while($row = mysql_fetch_assoc($result)) { if ($row['admin'] == 'admin'){ echo "ADMIN"; } } ?> Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bumpity Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 first off post all your code Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.