MyBB Community Forums

Full Version: MyBB - C# - Login & Check Usergroup
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the following problem. I have been crated a C# Login Program for my Forum.
This works relatively well so far.
However, all users can sign up there (except those that have their Acc not Activated)
I want that only the groups subscriber, Admin, Moderator can log in.
I hope anybody can help me

mysql_connect(PRIVAT, PRIVAT, PRIVAT);
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string(md5($_POST['password']));
$que = mysql_query("SELECT uid, password, salt FROM mybb_users WHERE username = '$username' LIMIT 1");
  die("Username not found.");  
  $row = mysql_fetch_assoc($que);  
  $uid = $row['uid'];  
  $salt = $row['salt'];  
  $hshed = $row['password'];  
  $input = md5(md5($salt).$password);
$objResult = mysql_query("SELECT uid FROM mybb_awaitingactivation WHERE uid = '$uid'");
$blnFound = (boolean) ($objResult) ? mysql_num_rows($objResult) : FALSE;
if($input != $hshed)
    if($blnFound == true)
        echo "activation";
        echo "good";
What you could do is edit your first query to use the IN condition in your WHERE CLause.

Something like this:
$que = mysql_query("SELECT uid, password, salt FROM mybb_users WHERE username = '$username'  AND usergroup IN(3,4,6) LIMIT 1");

3 is supermoderator, 4 is admin, and 6 is moderator. You'd just change those values to match your usergroups.