Login problem
#1

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. )
Reply
#2

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.
Reply
#3

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

Anyone?
Reply
#5

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;
}
Reply
#6

Doesn't work.
Reply
#7

I'm really trapped behind this... :S
Reply
#8

Bump!
Reply
#9

Anyone=
Reply
#10

Bumpp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)