Error mysql Login Pass
#1

PHP код:
forward MySQL_Login(playerid);
public 
MySQL_Login(playerid)
{
    
cache_get_field_content(0,"Username"pInfo[playerid][pUsername]);
    
cache_get_field_content(0"Password",pInfo[playerid][pPassword]);
    
pInfo[playerid][pXP] = cache_get_field_content_int(0"XP");
    
pInfo[playerid][pKills] = cache_get_field_content_int(0"Kills");
    
pInfo[playerid][pDeaths] = cache_get_field_content_int(0"Deaths");
    
pInfo[playerid][pRank] = cache_get_field_content_int(0"Rank");
    
pInfo[playerid][pEvac] = cache_get_field_content_int(0"Evac");
    
pInfo[playerid][pAdminLevel] = cache_get_field_content_int(0"AdminLevel");
    
pInfo[playerid][pVipLevel] = cache_get_field_content_int(0"VipLevel");
    
pInfo[playerid][pHour] = cache_get_field_content_int(0"Hour");
    
pInfo[playerid][pMin] = cache_get_field_content_int(0"Min");
    
pInfo[playerid][pSec] = cache_get_field_content_int(0"Sec");
    
pInfo[playerid][pMapsPlayed] = cache_get_field_content_int(0"MapsPlayed");
    
pInfo[playerid][pCoins] = cache_get_field_content_int(0"Coins");
    
pInfo[playerid][pLogged] = 1;
    
CheckBan(playerid);
    
playedtimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);
    return 
1;

Hello here is my problem

The password hen register he got save as hashed
I want when use it to be uset also login as hashed because i cant find the password in this line

cache_get_field_content(0, "Password",pInfo[playerid][pPassword]);

Here is and the Register

PHP код:
         case DIALOG_REGISTER:
        {
            if(
response)
            {
                if(!
strlen(inputtext) || strlen(inputtext) > 128)
                {
                    new 
string[128];
                    
SendClientMessage(playerid, -1""chat" You must insert a password between 1-128 characters!");
                     
format(string,sizeof(string),""chat" Hello %s to "NAME"",PlayerName(playerid));
                    
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD ,string,""chat" Welcome to "NAME" you'll be forced to register please click register!","Register","Quit");
                }
                else if(
strlen(inputtext) > && strlen(inputtext) < 128)
                {
                       new 
escpass[100];
                    
mysql_real_escape_string(inputtextescpass);
                    
MySQL_Register(playeridescpass);
                       
TextDrawHideForPlayer(playeridlogin0);
                     
TextDrawHideForPlayer(playeridlogin1);
                     
TextDrawHideForPlayer(playeridlogin2);
                     
TextDrawHideForPlayer(playeridlogin3);
                }
            }
            if(!
response)
            {
                
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must register to play at "NAME"","Close","");
                
Kick(playerid);
            }
        } 
Reply
#2

AnyOne Please
I want to get login as hashed
When account registered
He got register as hashed password

But

when the login is not ned password as hashed
Reply
#3

PHP код:
        case DIALOG_LOGIN:
        {
            if(!
response)
            {
                 
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must login to play at "NAME"","Close","");
                
Kick(playerid);
            }
            if(
response)
            {
                new 
query[256], pname[24];
                
GetPlayerName(playeridpname24);
                
mysql_format(mysqlquerysizeof(query), "SELECT `Username` FROM `users` WHERE Username = '%s' AND Password = SHA1('%s')"pnameinputtext);
                
mysql_tquery(mysqlquery"","");


                new 
numrows cache_num_rows();
                if(
numrows == 1Login_stock(playerid);
                
TextDrawHideForPlayer(playeridlogin0);
                
TextDrawHideForPlayer(playeridlogin1);
                
TextDrawHideForPlayer(playeridlogin2);
                
TextDrawHideForPlayer(playeridlogin3);

                if(!
numrows)
                {
                    new 
string[256];
                    
format(string,sizeof(string),""chat" Welcome back %s to "NAME"",PlayerName(playerid));
                    
ShowPlayerDialog(playeridDIALOG_LOGIN,DIALOG_STYLE_PASSWORD,string,""chat" Our system have detected your username registered please login","Login","Quit");
                }
            }
        } 
Here is and DIALOG_LOGIN

Can you please tell mee what is wrong here?
Reply
#4

Hmm Anyone ?
Reply
#5

Hello!

Can you share your MySQL_Register function?

Mencent
Reply
#6

PHP код:
stock MySQL_Register(playeridpasswordstring[])
{
    new 
Query[256],IP[16];
    
GetPlayerIp(playeridIPsizeof(IP));

    
strcat(Query,"INSERT INTO `users` (`Username`,`Password`,`pXP`,`pKills`,`pDeaths`,`pRank`, `pLevel`,`pAdminLevel`");
    
strcat(Query,",`pVipLevel`, `pHour`, `pMin`, `pSec`, `pMapsPlayed`, `pCoins`, `pIP`) VALUES ('%s',  SHA1('%s'),1,0,0,0,0,0,0,0,0,0,0,0,'%s')");
    
mysql_format(mysqlQuery,sizeof(Query),Query,PlayerName(playerid),passwordstring,IP);
    
mysql_tquery(mysqlQuery);

    
playedtimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);
    
pInfo[playerid][pLogged] = 1;
    
CheckBan(playerid);
    return 
1;

Done!
Reply
#7

Am soo verry sorry for this bump! but please i am need to fix this

Mencent can you fix this please ?
Reply
#8

Write it so, work this?
PHP код:
case DIALOG_LOGIN:
{
    if(!
response)
    {
        
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must login to play at "NAME"","Close","");
        
Kick(playerid);
    }
    if(
response)
    {
        new 
query[256], pname[24];
        
GetPlayerName(playeridpname24);
        
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `users` WHERE Username = '%s' AND Password = SHA1('%s')"pnameinputtext);
        
mysql_tquery(mysqlquery"MySQL_Login","i",playerid);
        
TextDrawHideForPlayer(playeridlogin0);
        
TextDrawHideForPlayer(playeridlogin1);
        
TextDrawHideForPlayer(playeridlogin2);
        
TextDrawHideForPlayer(playeridlogin3);
    }
}
        
forward MySQL_Login(playerid);
public 
MySQL_Login(playerid)
{
    if(!
cache_num_rows())
    {
        new 
string[256];
        
format(string,sizeof(string),""chat" Welcome back %s to "NAME"",PlayerName(playerid));
        
ShowPlayerDialog(playeridDIALOG_LOGIN,DIALOG_STYLE_PASSWORD,string,""chat" Our system have detected your username registered please login","Login","Quit");
    }
    
cache_get_field_content(0,"Username"pInfo[playerid][pUsername],mysql,MAX_PLAYER_NAME);
    
cache_get_field_content(0"Password",pInfo[playerid][pPassword],mysql,);//AFTER THE "," HAVE TO PUT IN THE LENGTH OF pPassword!!!
    
printf("Password: %s",pInfo[playerid][pPassword]);
    
pInfo[playerid][pXP] = cache_get_field_content_int(0"XP");
    
pInfo[playerid][pKills] = cache_get_field_content_int(0"Kills");
    
pInfo[playerid][pDeaths] = cache_get_field_content_int(0"Deaths");
    
pInfo[playerid][pRank] = cache_get_field_content_int(0"Rank");
    
pInfo[playerid][pEvac] = cache_get_field_content_int(0"Evac");
    
pInfo[playerid][pAdminLevel] = cache_get_field_content_int(0"AdminLevel");
    
pInfo[playerid][pVipLevel] = cache_get_field_content_int(0"VipLevel");
    
pInfo[playerid][pHour] = cache_get_field_content_int(0"Hour");
    
pInfo[playerid][pMin] = cache_get_field_content_int(0"Min");
    
pInfo[playerid][pSec] = cache_get_field_content_int(0"Sec");
    
pInfo[playerid][pMapsPlayed] = cache_get_field_content_int(0"MapsPlayed");
    
pInfo[playerid][pCoins] = cache_get_field_content_int(0"Coins");
    
pInfo[playerid][pLogged] = 1;
    
CheckBan(playerid);
    
playedtimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);
    return 
1;

Mencent
Reply
#9

PHP код:
stock Login_stock(playerid)
{
    new 
Query[256];
    
mysql_format(mysql,Querysizeof(Query), "SELECT * FROM users WHERE Username = '%e'"PlayerName(playerid));
    
mysql_tquery(mysqlQuery"MySQL_Login","i",playerid);

What about this i have and this also
Have this any problem ?

And 1 question: In your code if i use the password wrong i will not get again the password dialog to put it
and the textdraw will be hide before i use my succses password
Reply
#10

Delete this out of your script:
PHP код:
stock Login_stock(playerid)
{
    new 
Query[256];
    
mysql_format(mysql,Querysizeof(Query), "SELECT * FROM users WHERE Username = '%e'"PlayerName(playerid));
    
mysql_tquery(mysqlQuery"MySQL_Login","i",playerid);

And take my code. Well, work this now?

Mencent
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)