SA-MP Forums Archive
Login problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Login problem (/showthread.php?tid=396403)



Login problem - tsonn1 - 30.11.2012

Hi guys!
I've got a problem with my login script. I learned the MySQL stuff from ->https://sampforum.blast.hk/showthread.php?tid=305994 but there's a little bug in the login part.
About the bug. When you type in a wrong password or a right password, the script just logs u in.
When you type a wrong password, the script should say, that you've entered a wrong password, but it doesnt.

The code:
pawn Код:
stock LogMeIn(playerid,const password[])
{
    new EscapedText[60], Query[80], pName[24];
    GetPlayerName(playerid,pName,24);
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `name` = '%s' AND `pass` = '%s'",pName,EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        SendClientMessage(playerid,yello2,"U've just log'd in!");
        LoadStats(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, Valepass, DIALOG_STYLE_PASSWORD, "Wrong password!", "Wrong password!", "Login", "Leave");
    }
    mysql_free_result();
    return 1;
}
(I translated the code quickly, so u might find some mistakes. )


Re: Login problem - GiamPy. - 30.11.2012

pawn Код:
stock LogMeIn(playerid,const password[])
{
    new EscapedText[60], Query[80], pName[24];
    GetPlayerName(playerid,pName,24);
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT `pass` FROM `users` WHERE `name` = '%s' AND `pass` = '%s'", pName, EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        SendClientMessage(playerid,yello2,"U've just log'd in!");
        LoadStats(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, Valepass, DIALOG_STYLE_PASSWORD, "Wrong password!", "Wrong password!", "Login", "Leave");
    }
    mysql_free_result();
    return 1;
}
Try like this.


Re: Login problem - tsonn1 - 01.12.2012

Yea... Now I've got another problem. Iven if I type in the right password, it just says, that it's wrong.


Re: Login problem - tsonn1 - 01.12.2012

Anyone?


AW: Login problem - Skimmer - 01.12.2012

Try this.
pawn Код:
stock LogMeIn(playerid,const password[])
{
    new EscapedText[60], Query[80], pName[24];
    GetPlayerName(playerid,pName,sizeof(pName));
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `name` = '%s' AND `pass` = '%s'",pName,EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(!strlen(password))
    {
        ShowPlayerDialog(playerid, Valepass, DIALOG_STYLE_PASSWORD, "Wrong password!", "Wrong password!", "Login", "Leave");
        return 0;
    }
    if(mysql_num_rows() != 0)
    {
        SendClientMessage(playerid,yello2,"U've just log'd in!");
        LoadStats(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, Valepass, DIALOG_STYLE_PASSWORD, "Wrong password!", "Wrong password!", "Login", "Leave");
    }
    mysql_free_result();
    return 1;
}



Re: Login problem - tsonn1 - 01.12.2012

Doesn't work.


Re: Login problem - tsonn1 - 01.12.2012

I'm really trapped behind this... :S


Re: Login problem - tsonn1 - 02.12.2012

Bump!


Re: Login problem - tsonn1 - 02.12.2012

Anyone=


Re: Login problem - tsonn1 - 02.12.2012

Bumpp