papillonstudios Posted June 7, 2009 Share Posted June 7, 2009 ok i have a piece of code that is supposed to check for user and guest. and it does but now i want it to check for admin also. and if admin display both user and admin stuff, but of course it not heres my code <?php if ($uId) { if ($uCan) echo "<img src=\"i/user_go.png\">Hey! <STRONG>$uName</STRONG>"; // helo member! echo '<p>'; echo "<a href=\"index.php?action=editprofile\">Edit Profile</a> <br>"; echo "<a href=\"index.php?action=memberlist\">View Members</a> <br>"; echo "<a href=\"index.php?action=logout\">Logout</a> <br>"; echo '</p>'; echo "<br />"; } elseif ($uCan['admin']) { echo '<br />'; echo '<p><a href="index.php?action=admin"><strong>Admin</strong></a></p>'; } else { // if this isn't a member then echo "<img src=\"i/user_go.png\">Welcome, <STRONG>$uName</STRONG>!"; echo '<p>'; echo "<br>"; echo "<a href=\"index.php?action=login\">Login</a>"; echo "/"; echo "<a href=\"index.php?action=register\">Sign up</a>"; echo '</p>'; } echo "<BR>"; //break echo "<BR>"; // break ?> Quote Link to comment Share on other sites More sharing options...
XaeroDegreaz Posted June 7, 2009 Share Posted June 7, 2009 Are you sure that $uCan is an array? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 Remove else in the elseif. Just leave it as if. Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 for the first reply $permquery1 = mysql_query("SELECT * FROM `permissions` WHERE mg_name = '$uMembergroup' "); $uCan = mysql_fetch_assoc($permquery1); and for the second if i leave just an if, when a user logs in it displays the user and guest stuff Quote Link to comment Share on other sites More sharing options...
XaeroDegreaz Posted June 7, 2009 Share Posted June 7, 2009 Here is what I came up with. <?php if ($uId) { if ($uCan) { echo "<img src=\"i/user_go.png\">Hey! <STRONG>$uName</STRONG>"; // helo member! echo '<p>'; echo "<a href=\"index.php?action=editprofile\">Edit Profile</a> <br>"; echo "<a href=\"index.php?action=memberlist\">View Members</a> <br>"; echo "<a href=\"index.php?action=logout\">Logout</a> <br>"; echo '</p>'; echo "<br />"; //# This needs its own if statement... if ($uCan['admin']) { echo '<br />'; echo '<p><a href="index.php?action=admin"><strong>Admin</strong></a></p>'; } //###### } else { // if this isn't a member then echo "<img src=\"i/user_go.png\">Welcome, <STRONG>$uName</STRONG>!"; echo '<p>'; echo "<br>"; echo "<a href=\"index.php?action=login\">Login</a>"; echo "/"; echo "<a href=\"index.php?action=register\">Sign up</a>"; echo '</p>'; } echo "<BR>"; //break echo "<BR>"; // break ?> Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 nope the sidebar just disappears Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 and for the second if i leave just an if, when a user logs in it displays the user and guest stuff Mind showing me what you did there? It should look like this - <?php if ($uId) { if ($uCan) { echo "<img src=\"i/user_go.png\">Hey! <STRONG>$uName</STRONG>"; // helo member! echo '<p>'; echo "<a href=\"index.php?action=editprofile\">Edit Profile</a> <br>"; echo "<a href=\"index.php?action=memberlist\">View Members</a> <br>"; echo "<a href=\"index.php?action=logout\">Logout</a> <br>"; echo '</p>'; echo "<br />"; if ($uCan['admin']) { echo '<br />'; echo '<p><a href="index.php?action=admin"><strong>Admin</strong></a></p>'; } } } else { // if this isn't a member then echo "<img src=\"i/user_go.png\">Welcome, <STRONG>$uName</STRONG>!"; echo '<p>'; echo "<br>"; echo "<a href=\"index.php?action=login\">Login</a>"; echo "/"; echo "<a href=\"index.php?action=register\">Sign up</a>"; echo '</p>'; } echo "<BR>"; //break echo "<BR>"; // break Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 ok i got it to display the admin but when i login under an user account it doesn't diplays anything <?php if ($uId) { if ($uCan['user']) { echo "<img src=\"i/user_go.png\">Hey! <STRONG>$uName</STRONG>"; // helo member! echo '<p>'; echo "<a href=\"index.php?action=editprofile\">Edit Profile</a> <br>"; echo "<a href=\"index.php?action=memberlist\">View Members</a> <br>"; echo "<a href=\"index.php?action=logout\">Logout</a> <br>"; echo '</p>'; echo "<br />"; //# This needs its own if statement... } if ($uCan['admin']) { echo "<img src=\"i/user_go.png\">Hey! <STRONG>$uName</STRONG>"; // helo member! echo '<p>'; echo "<a href=\"index.php?action=editprofile\">Edit Profile</a> <br>"; echo "<a href=\"index.php?action=memberlist\">View Members</a> <br>"; echo "<a href=\"index.php?action=logout\">Logout</a> <br>"; echo '</p>'; echo "<br />"; echo '<br />'; echo '<p><a href="index.php?action=admin"><strong>Admin</strong></a></p>'; } } else { // if this isn't a member then echo "<img src=\"i/user_go.png\">Welcome, <STRONG>$uName</STRONG>!"; echo '<p>'; echo "<br>"; echo "<a href=\"index.php?action=login\">Login</a>"; echo "/"; echo "<a href=\"index.php?action=register\">Sign up</a>"; echo '</p>'; } echo "<BR>"; //break echo "<BR>"; // break ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 Before if ($uId) { , put this - var_dump($uId, $uCan); . What does that print out? Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 string(1) "2" array(6) { ["mg_id"]=> string(1) "1" ["mg_name"]=> string(4) "user" ["editprofile"]=> string(1) "1" ["viewprofile"]=> string(1) "1" ["admin"]=> string(1) "0" ["moderate"]=> string(1) "0" } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 Wait timeout, did you try the code I posted? Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 ya that what it gave me Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 7, 2009 Author Share Posted June 7, 2009 oh sorry man didnt see that post and it works thanks problem solved 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.