conker87 Posted June 28, 2007 Share Posted June 28, 2007 Here is the function I use to check if one is logged in: <?php function loveLogged() // Function to determine if the sessioned variables are correct, and therefore logged in. { $check = mysql_num_rows(mysql_query("SELECT * FROM ". MEMBER_TBL ." WHERE `username` = '".$_SESSION['username']."' AND `password` ='".$_SESSION['password']."'")); if ($check == 0) { return false; } else if ($check == 1) { return true; } else if ($check > 1) { return false; } } ?> Works great. But I'm wanting to add a little to it. For instance, my members area consists of groups: Admin, Villain, Writer, Fan, User all numbered (1-5 respectively). Only Admins, Villains and Writers are allowed to open the pages to add content to the site. I'm wanting to add to this function the ability to check for group < Writers, < Villains and Admins only. Maybe by using true and false values in the brackets? I'm fairly new to functions. And help appreciated. Quote Link to comment Share on other sites More sharing options...
no_one Posted June 28, 2007 Share Posted June 28, 2007 If groups are number represented (1-5) then adding something like " and group<=3" to the end of your query (where 3 would be Writer) should return a user only when they're given those privileges. 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.