MySQL Login fail ?
#1

Hello, i have a problem. I made a Login/Register system using MySql, but the problem now is the login. When you try to login even if you put the right password it dosen't work again. here's the onplayerpasswordresponse code:

pawn Код:
forward OnPasswordResponse(playerid);
public OnPasswordResponse(playerid)
{
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandel);
    if(num_fields==1)
    {
        iInfo[playerid][loggt] = 1;
       
        iInfo[playerid][score] = cache_get_field_content_int(0,"score",dbhandel);
    }
    else
    {
        SendClientMessage(playerid, BJELA, "Ukucana lozinka se ne poklapa sa ovim nalogom.");
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "UPISITE VASU LOZINK KAKO BI PRISTUPILI SERVERU.", "LOGIN", "OTKAZI");
    }
    return 1;
}
here's the onplayerdialogresponse:
pawn Код:
if(dialogid==DIALOG_LOGIN)
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME],query[128],password[255];
            GetPlayerName(playerid,name,sizeof(name));
            if(strlen(inputtext)>0)
            {
                mysql_escape_string(inputtext,password,dbhandel);
                format(query,sizeof(query),"SELECT * FROM acoounts WHERE username='%s' AND password='%s'",name,password);
                mysql_function_query(dbhandel,query,true,"OnPasswordResponse","i",playerid);
            }
            else
            {
                SendClientMessage(playerid,BJELA,"Upisite vasu lozinku!");
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "UPISITE VASU LOZINK KAKO BI PRISTUPILI SERVERU.", "LOGIN", "OTKAZI");
            }
        }
        else
        {
            Kick(playerid);
        }
        return 1;
    }
Oh and my database/tables
Reply
#2

Let's try this again. Forum crashed on my whilst posting.

1. Primary key is not auto increment
2. Typo in table name in SELECT
3. No encryption on password?
Reply
#3

Added the primary key on ID and AIed it, no typos found and what do you mean by encryption ? Still can't login
Reply
#4

Just for your information, you need to check if there are rows not if there is 1 field (which you have more).
pawn Код:
if(num_fields==1)
// to:
if(num_rows)
Also mamorunl means that you should hash the passwords of your players. Check Whirlpool thread for more information.
Reply
#5

Thank you guys! It works now
Reply
#6

Can you also please fix your signature? It is huge and breaks the forum lay-out.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)