Changing password problem
#1

pawn Код:
CMD:setpass(playerid, params[])
{
    new newpassword[15], oldpassword[15];
    if(sscanf(params, "s[15]s[15]", oldpassword, newpassword)) return SendClientMessage(playerid, -1, "USAGE: /setpass <oldpassword> <newpassword>");
    if(!pData[playerid][P_LOGGED]) return SendClientMessage(playerid, 0xE54500F1, "You mus be registered or logged in to change your password.");
    if(strlen(newpassword) < 4 || strlen(newpassword) > 15) return SendClientMessage(playerid, 0xE54500F1, "Invalid password lenght (min 4 / max 15).");
   
    new query[250], DBResult: result;
   
    format(query, sizeof(query), "SELECT * FROM `ACCOUNTS` WHERE `NAME` = LOWER('%s') AND `PASSWORD` = '%s'", DB_Escape(PlayerName(playerid)), DB_Escape(oldpassword));
    result = db_query(DataBase, query);
    if(db_num_fields(result))
    {
        db_free_result(result);
        format(query, sizeof(query), "UPDATE `ACCOUNTS` SET `PASSWORD` = '%s' WHERE `NAME` = LOWER('%s')", DB_Escape(newpassword), DB_Escape(PlayerName(playerid)));
        result = db_query(DataBase, query);
        db_free_result(result);
        SendClientMessage(playerid, 0xE2C86BFF, "Your password has been changed.");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, 0xE54500F1, "Old password doesn't much to the current one.");
        db_free_result(result);
    }
    return 1;
}
There is a problem with this command. When someone tries to change his password it says the current one doesn't much. I have printed out the queries. Seems to be printed fine.

Can anyone see any problem with this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)