MySQL Issues
#4

Ahhh... derp.
Now, I have another issue I can't seem to find by search (Maybe I'm blind).
How would I compare Inputtext from a login dialog with a password in the database that was put into the database using "md5('%s').

The Code I have:
pawn Код:
case DIALOG_LOGIN:
        {
            if (!response) return Kick (playerid);
            if(response)
            {
                new query[128];
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","{FFFFFF}Please Enter your password below to login. \n\nCannot be blank!","Login","Exit");
                format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name`='%s' AND `Pass`=md5('%s')", PlayerInfo[playerid][Name], PlayerInfo[playerid][pPass]);
                mysql_function_query(handle, query, true, "OnAccountLoad", "d", playerid);
                /*if(inputtext == PlayerInfo[playerid][pPass]) //How Would I compare inputtext with Password stored?
                {
                    LoadAccount(playerid);
                }
                else
                {
                    if(LogginAttempts[playerid] == 2)
                    {
                        LogginAttempts[playerid] = 0;
                        Kick(playerid);
                    }
                    else
                    {
                        LogginAttempts[playerid]++;
                        new str[1024], string[256];
                        format(string, sizeof(string), "{FF4000}Incorrect Password   Attempts: %d\n", LogginAttempts[playerid]);
                        strcat(str, string);
                        format(string, sizeof(string), "{FFFFFF}You will be kicked after 3 attempts.\n");
                        strcat(str, string);
                        format(string, sizeof(string), "{FFFFFF}Please type your password below to login.\n");
                        strcat(str, string);
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login:", str, "Login", "Exit");
                    }
                }*/

            }
        }
Things that may help...
pawn Код:
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
        SetCameraBehindPlayer(playerid);
        PlayerInfo[playerid][pCash] = cache_get_row_int(0,3,handle),
        PlayerInfo[playerid][pAdmin] = cache_get_row_int(0,4,handle),
        PlayerInfo[playerid][pSex] = cache_get_row_int(0,5,handle),
        PlayerInfo[playerid][pSkin] = cache_get_row_int(0,6,handle),
        PlayerInfo[playerid][pAge] = cache_get_row_int(0,7,handle),
        PlayerInfo[playerid][PosX] = cache_get_row_float(0,8,handle),
        PlayerInfo[playerid][PosY] = cache_get_row_float(0,9,handle),
        PlayerInfo[playerid][PosZ] = cache_get_row_float(0,10,handle),
        PlayerInfo[playerid][FaceA] = cache_get_row_float(0,11,handle),
        PlayerInfo[playerid][Interior] = cache_get_row_int(0,12,handle),
        PlayerInfo[playerid][VirtualWorld] = cache_get_row_int(0,13,handle),
        PlayerInfo[playerid][CellNum] = cache_get_row_int(0,14,handle),
        PlayerInfo[playerid][Job] = cache_get_row_int(0,15,handle),
        PlayerInfo[playerid][Accent] = cache_get_row_int(0,16,handle),
        PlayerInfo[playerid][Faction] = cache_get_row_int(0,17,handle),
        PlayerInfo[playerid][Hospital] = cache_get_row_int(0,18,handle),
        PlayerInfo[playerid][Insurance] = cache_get_row_int(0,19,handle);
        LoggingIn[playerid] = 1;
        return 1;
}

stock CreateAccount(playerid,pass[])
{
        new query[240], name[24];
        GetPlayerName(playerid, name, sizeof(name));
        format(query, sizeof(query), "INSERT INTO `accounts` (Name,Pass) VALUES (\'%s\', \'md5('%s')\')", name, pass);
        mysql_function_query(handle, query, false, "SendQuery", "");
}

stock LoadAccount(playerid)
{
        new query[128];
        format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name`='%s'", PlayerInfo[playerid][Name]);
        mysql_function_query(handle, query, true, "OnAccountLoad", "d", playerid);
}
Reply


Messages In This Thread
MySQL Issues - by Jacksta21 - 22.05.2014, 15:27
Re: MySQL Issues - by Konstantinos - 22.05.2014, 15:29
Re: MySQL Issues - by RajatPawar - 22.05.2014, 15:32
Re: MySQL Issues - by Jacksta21 - 22.05.2014, 15:35
Re: MySQL Issues - by RajatPawar - 22.05.2014, 15:41
Re: MySQL Issues - by Jacksta21 - 22.05.2014, 15:44
Re: MySQL Issues - by RajatPawar - 22.05.2014, 15:49
Re: MySQL Issues - by Jacksta21 - 22.05.2014, 18:23
Re: MySQL Issues - by Vince - 22.05.2014, 20:02
Re: MySQL Issues - by AiRaLoKa - 23.05.2014, 01:27

Forum Jump:


Users browsing this thread: 1 Guest(s)