[Help] Password change.
#1

Hey guys, i use mysql, i want to make a command that allows players to change their own passwords, Lethal helped me out by giving me this code.

PHP код:
CMD:changepass(playeridparams[])
{
    new
        
EscPass[40],
        
Query[128],
        
iStr[55];
    if(
isnull(params)) return SendClientMessage(playerid, -1""#CRED"Usage: "#CORANGE"/ChangePass < New Password >");
    
mysql_real_escape_string(paramsEscPass);
    
format(Querysizeof(Query), "UPDATE `playerinfo` SET `password` = md5('%s') WHERE `user` = '%s'"EscPasspName(playerid));
    
mysql_query(Query);
   
    
format(iStrsizeof(iStr), "You've changed your password to: "#CBLUE"%s", params);
    
SendClientMessage(playerid, -1iStr);
    return 
1;

At the end it tells me that i've changed my password to: BlaBla.
In reality tho, it does not change it in database, am i missing some code? Please help, thanks.
Reply
#2

I believe you need a place for it to save, an accountpath

pawn Код:
if(sscanf(params, "ss", oldpass, newpass)) SendUsage(playerid, "USAGE: /changepass [old password] [new password]");
    else
    {
        new accountpath[64]; format(accountpath, sizeof(accountpath), "%s", AccountPath(playerid));
        new buf[129];
        WP_Hash(buf, sizeof(buf), oldpass);
        if(strcmp(dini_Get(accountpath, "password"), oldpass, true) == 0)
        {
            WP_Hash(buf, sizeof(buf), newpass);
            dini_Set(accountpath, "password", newpass);
            SendClientMessage(playerid, COLOR_GREEN, "SUCCESS: You have changed your password.");
        }
Reply
#3

Solved!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)