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 Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/ Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bump..... Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599119 Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 what? your question doesnt make any sense Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599125 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 Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599128 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 Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599130 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] Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599132 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. Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599142 Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 no session is started Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599144 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.. Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599146 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']; ?> Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599151 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 Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599154 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 Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599164 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']}"; Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599167 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. Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599172 Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bump Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599191 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"; } } ?> Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599201 Share on other sites More sharing options...
ronnie88 Posted July 25, 2008 Author Share Posted July 25, 2008 friendly bumpity Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599227 Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 first off post all your code Link to comment https://forums.phpfreaks.com/topic/116510-im-trying/#findComment-599395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.