#1

Hello every time i try to login it say wrong even if it correct password help me please


PHP код:
[22:12:30] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
22:12:30] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
22:12:30] [DEBUGCMySQLConnection::Connect connection was successful
[22:12:30] [DEBUGCMySQLConnection::Connect connection was successful
[22:12:30] [DEBUGCMySQLConnection::Connect connection was successful
[22:12:30] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:12:30] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:12:30] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:12:58] [DEBUGmysql_format connection1len500format"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"
[22:12:58] [DEBUGmysql_tquery connection1query"SELECT `Password`, `ID` FROM `players` WHERE `Username` = 'LMAOO"callback"CheckPlayer"format"i"
[22:12:58] [DEBUGCMySQLQuery::Execute[CheckPlayer] - starting query execution
[22:12:58] [DEBUGCMySQLQuery::Execute[CheckPlayer] - query was successfully executed within 0.980 milliseconds
[22:12:58] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[22:12:58] [DEBUGCalling callback "CheckPlayer"..
[
22:12:58] [DEBUGcache_get_data connection1
[22:12:58] [DEBUGcache_get_field_content row0field_name"Password"connection1max_len129
[22:12:58] [DEBUGCMySQLResult::GetRowDataByName row'0'field"Password"data"FD9D94340DBD72C11B37EBB0D2A19B4D05E00FD78E4E2CE8923B9EA3A54E900DF181CFB112A8A73228D1F3551680E2AD9701"
[22:12:58] [DEBUGcache_get_field_content_int row0field_name"ID"connection1
[22:12:58] [DEBUGCMySQLResult::GetRowDataByName row'0'field"ID"data"22"
[22:12:58] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called
[22:13:14] [DEBUGmysql_format connection1len500format"UPDATE `players` SET `Adminstator`=%d, `VIP`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f, `Kills`=%d, `Deaths`=%d, `Kicked`=..."
[22:13:14] [DEBUGmysql_tquery connection1query"UPDATE `players` SET `Adminstator`=0, `VIP`=0, `Money`=0, `posX`"callback"(null)"format"(null)"
[22:13:14] [DEBUGCMySQLQuery::Execute[] - starting query execution
[22:13:14] [DEBUGCMySQLQuery::Execute[] - query was successfully executed within 94.418 milliseconds
[22:13:14] [DEBUGCMySQLQuery::Execute[] - no callback specifiedskipping result saving
[22:32:07] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
22:32:07] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
22:32:07] [DEBUGCMySQLConnection::Connect connection was successful
[22:32:07] [DEBUGCMySQLConnection::Connect connection was successful
[22:32:07] [DEBUGCMySQLConnection::Connect connection was successful
[22:32:07] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:32:07] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:32:07] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[22:32:30] [DEBUGmysql_format connection1len500format"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"
[22:32:30] [DEBUGmysql_tquery connection1query"SELECT `Password`, `ID` FROM `players` WHERE `Username` = 'LMAOO"callback"CheckPlayer"format"i"
[22:32:30] [DEBUGCMySQLQuery::Execute[CheckPlayer] - starting query execution
[22:32:30] [DEBUGCMySQLQuery::Execute[CheckPlayer] - query was successfully executed within 0.649 milliseconds
[22:32:30] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[22:32:30] [DEBUGCalling callback "CheckPlayer"..
[
22:32:30] [DEBUGcache_get_data connection1
[22:32:30] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called
[22:32:33] [DEBUGmysql_format connection1len500format"INSERT INTO `players` (`Username`, `Password`, `IP`, `Adminstator`, `VIP`, `Money`, `posX` ,`posY`, `posZ`, `Kills`, `Deaths`, `..."
[22:32:33] [DEBUGmysql_tquery connection1query"INSERT INTO `players` (`Username`, `Password`, `IP`, `Adminstato"callback"IsAccountRegister"format"i"
[22:32:33] [DEBUGCMySQLQuery::Execute[IsAccountRegister] - starting query execution
[22:32:33] [DEBUGCMySQLQuery::Execute[IsAccountRegister] - query was successfully executed within 71.485 milliseconds
[22:32:33] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[22:32:33] [DEBUGCalling callback "IsAccountRegister"..
[
22:32:33] [DEBUGcache_insert_id connection1
[22:32:33] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called
[22:32:36] [DEBUGmysql_format connection1len500format"UPDATE `players` SET `Adminstator`=%d, `VIP`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f, `Kills`=%d, `Deaths`=%d, `Kicked`=..."
[22:32:36] [DEBUGmysql_tquery connection1query"UPDATE `players` SET `Adminstator`=0, `VIP`=0, `Money`=0, `posX`"callback"(null)"format"(null)"
[22:32:36] [DEBUGCMySQLQuery::Execute[] - starting query execution
[22:32:36] [DEBUGCMySQLQuery::Execute[] - query was successfully executed within 76.313 milliseconds
[22:32:36] [DEBUGCMySQLQuery::Execute[] - no callback specifiedskipping result saving 
PHP код:
public CheckPlayer(playerid)
{
    new 
rowsfields;
    
cache_get_data(rows,fields,mysql);
    if(
rows)
    {
        
cache_get_field_content(0"Password"pdata[playerid][Password], mysql129);
        
pdata[playerid][ID] = cache_get_field_content_int(0,"ID");
        
ShowPlayerDialog(playerid,4,DIALOG_STYLE_PASSWORD,"Login","Please enter your password blow to login","Login","Close");
    }
    else
    {
      
ShowPlayerDialog(playerid3DIALOG_STYLE_PASSWORD,"Register","Please enter your password blow to register on our server","Register","Close");
    }
    return 
1;

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
4:
        {
            if(
response)
            {
              new 
hpass[129];
              new 
query[500];
              
WP_Hash(hpass129inputtext);
              if(!
strcmp(hpasspdata[playerid][Password]))
              {
                
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1"Name[playerid]);
                
mysql_tquery(mysqlquery"AccountIsFound""i"playerid);
              }
              else
              {
                
ShowPlayerDialog(playerid4DIALOG_STYLE_INPUT"Login""In order to play, you need to login\nWrong password!""Login""Quit");
              }
           }
        }
        case 
3:
        {
            if(
response)
            {
               if(
strlen(inputtext) < 6) return ShowPlayerDialog(playerid3DIALOG_STYLE_INPUT"Register""In order to play, you need to register.\nYour password must be at least 6 characters long!""Register""Quit");
               new 
query[500];
               
WP_Hash(pdata[playerid][Password], 129inputtext);
               
mysql_format(mysqlquerysizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Adminstator`, `VIP`, `Money`, `posX` ,`posY`, `posZ`, `Kills`, `Deaths`, `Kicked`, `Skin`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0, 0, 0, 0, 0)"Name[playerid], pdata[playerid][Password], IP[playerid]);
               
mysql_tquery(mysqlquery"IsAccountRegister""i"playerid);
           }
        }
    }
    return 
1;

Reply
#2

Just some tips:

Use an enum/defines for the dialogid's.

that way you'll have

case DIALOG_REGISTER:

case DIALOG_LOGIN:

Which is much easier to read and understand, without actually seeing the code inside.

2nd, your password variable (pdata[playerid][password]), is it size 129 aswell? (Just making sure)

pawn Код:
new hashed_pass[129];
WP_Hash(hashed_pass, sizeof(hashed_pass), inputtext);

if(strcmp(hashed_pass, Player[playerid][Password]) == 0)
{

}
That's what I'm using, and it works. Last but not least, the insert query..

Let's see if it works correctly: debug your hashed pass by pasting it in the console, and check if it's the same as the password in your database.
Reply
#3

didnt work
Reply
#4

Do something like that and show result:
Код:
print(inputtext);
print(hpass);
print(pdata[playerid][Password]);
Before
Код:
if(!strcmp(hpass, pdata[playerid][Password]))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)