changepass mysql [+REP]
#1

hi guys i make a cmd for player change his password it change in mysql database but the proble is
when i change my pass it doesn't check if the old pass if correct plz help

pawn Код:
CMD:changepass(playerid,params[])
{
    new oldpass[128];
    new query[313], name[24], WPhash[145], escape[145];
    if(sscanf(params, "s[128]s[128]", oldpass, WPhash)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changepass (Old Password) (New Password)");
    //else if(oldpass == wrongpassword) return SendClientMessage(playerid, COLOR_ERROR, "Error: Wrong 'Old password'");
    {
        GetPlayerName(playerid,name,24);
        mysql_real_escape_string(oldpass, escape);
        WP_Hash(WPhash, sizeof(WPhash), escape);
        mysql_format(mysql, query, sizeof(query), "UPDATE `Players` SET `Password` = '%s' WHERE `Username` = '%s'", WPhash, name);
        mysql_query(mysql, query,"", "");
        SendClientMessage(playerid, COLOR_GREEN, "Password Changed!");
    }
    return 1;
}
sorry for my bad english

best regards
Reply
#2

The variable "oldpass" is returning "null".
Reply
#3

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
The variable "oldpass" is returning "null".
plz explain more
Reply
#4

What enum do you store your current/ oldpassword in? Because the command isn't going to store that data for you.

Also, This check:
Код:
//else if(oldpass == wrongpassword)
Will not work at all, Use strcmp since you are comparing strings.
Reply
#5

you need to select that table and column then get data from it and load it into oldpass in cmd
Reply
#6

i remove oldpass variable i don't need it anymore xD [SOLVED]
pawn Код:
CMD:changepass(playerid,params[])
{
    new query[313], name[24], WPhash[145], escape[145];
    if(sscanf(params, "s[128]", WPhash)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changepass (New Password)");
    {
        GetPlayerName(playerid,name,24);
        mysql_real_escape_string(oldpass, escape);
        WP_Hash(WPhash, sizeof(WPhash), escape);
        mysql_format(mysql, query, sizeof(query), "UPDATE `Players` SET `Password` = '%s' WHERE `Username` = '%s'", WPhash, name);
        mysql_query(mysql, query,"", "");
        SendClientMessage(playerid, COLOR_GREEN, "Password Changed!");
    }
    return 1;
}
thanks for everyone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)