MYSQL Login System[BUGGED]
#1

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;

Reply
#2

Any suggestions?
Reply
#3

Show pVariables[playerid][pPassword]
Reply
#4

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

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

Anyone?
Reply
#7

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'.
Reply
#8

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
Reply
#9

None of these work
Reply
#10

Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)