Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: Probelm with MySQL register.

  1. #21
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    SearchForLogin() doesnt return a value.

    As I wrote you on blizo.de, you should definately watch/read some basic scripting tutorials first like https://killtube.org/showthread.php?...ng-brushmodels

  2. #22
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    PHP Code:
    case "register":
            
    login args[2];
            
    pass args[3];
                if(
    args[2].size >= && args[2].size <= 20)
                {
                    if(
    args[3].size >= && args[3].size <= 25)
            {
            
    iprintlnbold("login check");
                    if(
    searchforlogin(args[2]) == true)
                    {
            
    iprintlnbold("Name exist !");
            return;
            }
            if(
    searchforlogin(args[2]) == false)
            {
            
    iprintlnbold("TEST");
            
    wait 5;
            
    self thread createadmin(args[2], args[3]);
            
    self iprintlnbold("OK");
            return;
            }
            return;
        }
                
    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; 
    PHP Code:
    CreateAdmin(loginpass)
    {
        
    self thread tellmessage("success");
        return 
    maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO admins (login, pass) VALUES ('" maps\mp\gametypes\_mysql::stripString(login) + "', '" maps\mp\gametypes\_mysql::stripString(pass) + "')");
    }

    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 thread tellmessage("already exist");
            return 
    true;
       }
        return 
    false;


    Guys please correct it for me. i'm just bored of doing all solutions in my mind without success.
    It just doesn't create account when the login is available.
    Please izno,voron, anyone who can help .. :s

  3. #23
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Something like this might work:

    PHP Code:
    checklogin(usernamepassword)
    {
        
    args = [];
        
    args[0] = "login";
        
    self asyncQuery("SELECT userid FROM users WHERE username = '" stripstring(username) + "' AND password = '" stripstring(password) + "'", ::receivelogin);
    }

    recievelogin(rowsargs)
    {
        if(
    rows.size && isdefined(rows[0]) && isdefined(rows[0]["userid"]))
        {
            
    self.userid int(rows[0]["userid"]);
            if(
    args[0] == "login")
                
    self iprintlnbold("Login completed");
            else
                
    self iprintlnbold("Register succesful");
        }
        else
        {
            if(
    args[0] == "login")
                
    self iprintlnbold("Login failed. Wrong password?");
            else
                
    self iprintlnbold("Register failed. User already exists");
        }
    }

    registeraccount(usernamepassword)
    {
        
    args = [];
        
    args[0] = "register";
        
    self asyncQuery("SELECT create_new_account() AS `userid`", ::receiveloginargs);

    mysql function:
    PHP Code:
    CREATE DEFINER=`root`@`127.0.0.1` FUNCTION `createNewAccount`(`_usernameCHAR(50), `_passwordCHAR(50))
        
    RETURNS int(11)
        
    LANGUAGE SQL
        NOT DETERMINISTIC
        CONTAINS SQL
        SQL SECURITY DEFINER
        COMMENT 
    ''
    BEGIN
        
    DECLARE _userid INT DEFAULT NULL;
        
    SELECT LAST_INSERT_ID(NULLINTO _userid;
        
    INSERT IGNORE INTO users (useridloginpasswordVALUES (NULL_login_password);
        
    SELECT LAST_INSERT_ID() INTO _userid;
        RETURN 
    _userid;
    END 
    Untested.

    Needs a table "users" with primary key "userid" with auto-increment, a unique login (char(50)) and non-unique password (char(50))
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. #24
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    How to execute that mysql function ? i tried with heidisql/phpmyadmin sql executer but it gives me error
    PHP Code:
    SQL query:

    CREATE DEFINER =  `root`@`127.0.0.1` FUNCTION  `createNewAccount` (

    `
    _usernameCHAR50 ) ,
    `
    _passwordCHAR50 )
    RETURNS INT11 LANGUAGE SQL NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT  '' BEGIN DECLARE _userid INT DEFAULT NULL ;

    MySQL saidDocumentation

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 

  5. #25
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Sorry for double post. i managed to execute these functions by mysql -u root -p , then delimiter // , i wrote the fuctions then i didi end //

  6. #26
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    I did everything. Created the database,table,columns, but the problem now is the case "register", i don't know how to order the queries.
    i tried this but it gives me user already exists everytime
    PHP Code:
    case "register":
            if(
    args[2].size >= && args[2].size <= 20
                { 
                    if(
    args[3].size >= && args[3].size <= 25)
            {
            
    registeraccount(args[2], args[3]);
            return;
              }
            
    self thread tellmessage("pw too short/long");
            return;
        }
        
    self thread tellmessage("user too short/long"); 
    thx izno and sorry for annoying u ik u are bored. but can u help me pls ?

  7. #27
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    PHP Code:
    registeraccount(usernamepassword)
    {
        
    args = [];
        
    args[0] = "register";
        
    self asyncQuery("SELECT create_new_account() AS `userid`", ::receiveloginargs);

    ->
    PHP Code:

    registeraccount
    (usernamepassword)
    {
        
    args = [];
        
    args[0] = "register";
        
    self asyncQuery("SELECT create_new_account('" stripstring(username) + "', '" stripstring(password) + "') AS `userid`", ::receiveloginargs);

    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. #28
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Still the same error.
    registration failed, already exist
    Last edited by nightbot; 25th July 2016 at 09:49.

  9. #29
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    are you sure your table has a primarykey with autoincrement called userid?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  10. #30
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Click image for larger version. 

Name:	auto.PNG 
Views:	31 
Size:	219.1 KB 
ID:	1195

    check is izno.

Posting Permissions

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