SA-MP Forums Archive
MYSQL Login System[BUGGED] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL Login System[BUGGED] (/showthread.php?tid=514307)



MYSQL Login System[BUGGED] - guitardude01 - 20.05.2014

I have a login and register system that uses MYSQL. For some reason, even if the user enters the right or wrong password, it says that the password is incorrect, any suggestions?


PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
name1[MAX_PLAYER_NAME+1];
    
GetPlayerName(playeridname1sizeof(name1));
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD""COL_WHITE"Registering...",""COL_RED"You have not entered a password.\n"COL_WHITE"Type a password below to register a new account.","Register","Quit");
                
WP_Hash(pVariables[playerid][pPassword], 129inputtext);
                
pVariables[playerid][pMoney] = 1500;
                
mysql_format(mysqlquerysizeof(query), "INSERT INTO `users` (`Username`, `Password`, `IP`, `Admin`, `Helper`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`) VALUES ('%s', '%s', '%s', 0, 0, 0, 1500, '%f', '%f', '%f')"Name[playerid], pVariables[playerid][pPassword], IP[playerid], Spawn_XSpawn_YSpawn_Z);
                
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid);
            }
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) return Kick playerid );
            if( 
response )
            {
                new 
hpass[129];
                
WP_Hash(hpass129inputtext);
                if(!
strcmp(hpasspVariables[playerid][pPassword]))
                {
                    
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1"name1);
                    
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 
1;
            }
        }
    }
    return 
1;




Re: MYSQL Login System[BUGGED] - guitardude01 - 21.05.2014

Any suggestions?


Re: MYSQL Login System[BUGGED] - ball - 21.05.2014

Show pVariables[playerid][pPassword]


Re: MYSQL Login System[BUGGED] - guitardude01 - 21.05.2014

PHP код:
pVariables[playerid][pPassword] = cache_get_field_content(0"Password"dest); 



Re: MYSQL Login System[BUGGED] - guitardude01 - 21.05.2014

Ok, its getting what they're typed in, but it wont retrieve their real password. When it trys to retrieve it, it says NULL.


Re: MYSQL Login System[BUGGED] - guitardude01 - 23.05.2014

Anyone?


Re: MYSQL Login System[BUGGED] - DobbysGamertag - 23.05.2014

Have you read the documentation?

pawn Код:
cache_get_field_content(row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination))
So for you:
pawn Код:
cache_get_field_content(0,"Password",pVariables[playerid][pPassword],dbhandle,sizeof(pVariables[playerid][pPassword]));
Then try:

pawn Код:
printf("%s",pVariables[playerid][pPassword]);
Just in-case you're on a windows server with MySQL. The field names are converted to lowercase occasionally. So 'Password' may be 'password'.


Re: MYSQL Login System[BUGGED] - Fred1993 - 23.05.2014

in my sql i use this command to save the password in database
Quote:

mysql_real_escape_string(inputtext, inputtext);

It works fine for me..
it stores the password as the user entered, and also you can compair it when the user enter password on login


Re: MYSQL Login System[BUGGED] - guitardude01 - 25.05.2014

None of these work


Re: MYSQL Login System[BUGGED] - guitardude01 - 26.05.2014

Anyone?