Page 1 of 4 123 ... LastLast
Results 1 to 10 of 40

Thread: Probelm with MySQL register.

  1. #1
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Probelm with MySQL register.

    Hello, i've been trying to make a register command. But it allows 2 usernames on database without having an error ingame.
    I'm tired working on this since 4 days with no success.
    These are codes guys
    PHP Code:
    CreateAdmin(loginpassword)
    {
        
    maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO admins (login, password) VALUES ('" maps\mp\gametypes\_mysql::stripString(login) + "', '" maps\mp\gametypes\_mysql::stripString(password) + "')");
        
    self thread tellMessage("Succes! Your account has been created.");
    }
    SearchForLogin(login)
    {
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT login FROM admins WHERE login = '" maps\mp\gametypes\_mysql::stripString(login) + "' LIMIT 1", ::checkLogin);
    }

    checkLogin(rowsargs)
    {    
       if(
    isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["login"]) && isDefined(self))
       {

            
    self tellMessage("I'm sorry, but login " rows[0]["login"] + "^7 already exist. Choose another one.");
            return;
       }


    The register statement :
    PHP Code:
    case "register":
                       if(
    args[2].size >= && args[2].size <= 20)
                       {
                           if(
    args[3].size >= && args[3].size <= 25)
                           {
                               
    SearchForLogin(args[2]);
                    
    wait 3;
                    if(
    isDefined(args[2]) && isDefined(args[3]))
                    
    checklogin(args[2]);
                    
    createadmin(args[2], args[3]);
                               return;
                           }
                           else
                           {
                               
    self thread tellMessage("Password is too short or too long. Min 5 characters, max 25.");
                               return;
                           }
                       }
                    
    self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
                       return; 
    Please guys help !

  2. #2
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    bump
    10char

  3. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  4. #3
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Omg, where query's? D

  5. The Following User Says Thank You to maxdamage99 For This Useful Post:

    Paho (23rd July 2016)

  6. #4
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    could you fix it for me?

  7. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  8. #5
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    i no use async, i can fix by simple
    Code:
    mysql_query

  9. The Following User Says Thank You to maxdamage99 For This Useful Post:

    Paho (23rd July 2016)

  10. #6
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Ok give it

  11. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  12. #7
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by nightbot View Post
    could you fix it for me?
    You can restrict double values with UNIQUE.
    Your problem isn't the database, but how you process the results.
    E.g.
    PHP Code:
    case "register"
       
    hasLogin searchForLogin(username); 
       if (!
    hasLogin) {
          
    createAdmin(usernamepassword);
       } 
    Note: this is not working code that you can just copy and paste and use. Just an example.

  13. The Following User Says Thank You to Mitch For This Useful Post:

    nightbot (23rd July 2016)

  14. #8
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Ahaa ! But can you give me atleast a good start for it ? I'm not that good at mysql things tbh mitch

  15. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  16. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Create a UNIQUE key constraint in your mysql db. Then use a stored procedure (function) to create new accounts, which use a INSERT IGNORE. Then double-check on last_insert_id inside that function. Return something if successful (possibly the user's ID), and an error code if unsuccessful (-1 should do a decent job at being an error code)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  17. The Following User Says Thank You to IzNoGoD For This Useful Post:

    nightbot (23rd July 2016)

  18. #10
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by nightbot View Post
    I'm not that good at mysql things tbh
    Every single thing u said didn't understand anything from. Maybe a small tutorial or some links.
    If u wants to help me i will just have 3 columns login password rank in admins table.

  19. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

Posting Permissions

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