Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: PHP Question

  1. #1
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default PHP Question

    Hi everyone, just a wee question.

    I have been working on a small personal project for a while now, got the majority of it done, but this next bit is stumping me.

    I have a basic MySQL Database and login system, Now I have a field in the Database called MABANNED, Now I was to do something like when they try and log in it checks against this field, If 1 show "You have been banned" and if 0 carry on loading the dashboard.

    But, I've tried a few different methods and I cannot get it to work, any help?

    moderator alert Moved by Lee (Forum Super Moderator): From 'Tech Discussion'.
    Last edited by Lee; 08-11-2012 at 04:23 PM.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    What methods have you tried?

  3. #3
    Join Date
    Mar 2005
    Location
    London
    Posts
    4,402
    Tokens
    3,894
    Habbo
    Intricat

    Latest Awards:

    Default

    Code:
    $query = mysql_query("SELECT MABANNED FROM Table_Name WHERE username='TheirUsername'");
    
    if($query = 1) { Show a banned message } else { Show the login area }
    Put that in the area where it logs them in, so if they're banned, show the message, else process the login. I think that should work. If MABANNED isn't in the same table as their username, you'll have to join them together using IDs.
    Last edited by Kieran; 08-11-2012 at 02:27 PM.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Don't really do much PHP anymore but I'm fairly sure you should not be using the old MySQL functions and be using PDO/MySQLi

    Quote Originally Posted by Kieran View Post
    Code:
    $query = mysql_query("SELECT MABANNED FROM Table_Name WHERE username='TheirUsername'");
    
    if($query = 1) { Show a banned message } else { Show the login area }
    Put that in the area where it logs them in, so if they're banned, show the message, else process the login. I think that should work.

  5. #5
    Join Date
    Mar 2005
    Location
    London
    Posts
    4,402
    Tokens
    3,894
    Habbo
    Intricat

    Latest Awards:

    Default

    Quote Originally Posted by Tomm View Post
    Don't really do much PHP anymore but I'm fairly sure you should not be using the old MySQL functions and be using PDO/MySQLi
    Depends how he has done the rest.

  6. #6
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Well obviously but there is no reason to be using the old MySQL functions unless you're working on a legacy project.

    Quote Originally Posted by Kieran View Post
    Depends how he has done the rest.

  7. #7
    Join Date
    Mar 2005
    Location
    London
    Posts
    4,402
    Tokens
    3,894
    Habbo
    Intricat

    Latest Awards:

    Default

    Quote Originally Posted by Tomm View Post
    Well obviously but there is no reason to be using the old MySQL functions unless you're working on a legacy project.
    Depends if he's new to it. I know the book I used which wasn't particularly old started you off on the legacy API. It didn't mention PDO until near the end of the book.

  8. #8
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Sigh, this is why I don't like PHP and its whole ecosystem. Really there should not be 3 different ways of using MySQL in your project, but that is what you get from a poorly designed language that is trying to patch things up years from it initial creation. If the book was fairly new then it seems completely idiotic to encourage people new to the language to use an extension that is strongly not recommended for use any more and will, at some point, be deprecated and removed. Not like the procedural version of MySQLi is significantly more complicated.

    Quote Originally Posted by Kieran View Post
    Depends if he's new to it. I know the book I used which wasn't particularly old started you off on the legacy API. It didn't mention PDO until near the end of the book.
    Last edited by Tomm; 08-11-2012 at 02:52 PM.

  9. #9
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    What I have learned has been threw together from guides, working things out for myself and what not, I'll try it, its in the same table so hopefully that will work, I get the feeling I have used many different types of PHP and MySQL throughout, but meh, its not for anything major.

  10. #10
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Sorry for the double post, did this in the end:

    Code:
    $query = mysql_query("SELECT mabanned FROM `users` WHERE username='" . $username . "'");
    		$row = mysql_fetch_array($query);
    		
    		if($row['mabanned'] > 0) {
    			die("You have been banned from logging in.");
    		}

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •