MYSQL help
#1

I have added this into my script, https://sampforum.blast.hk/showthread.php?tid=485633&page=11 .

But the problem is once i registered and then re-join and when i enter my password it said wrong password.

I have checked ppl replied there in this thread and did what they said. But still getting can't login. it says wrong password:

My code is here: if you need more code please let me know. Thanks

PHP код:
enum PDATA //We name our enumerator as PDATA (which stands for PlayerDATA). You can name it however you want.
{
    
IDs//Will be used later to store player's ID from database so we can use it anywhere later
    
Password[129], //We will load player's password into this varible from database
    
Admin//We will load player's admin level from database into this variable so we can use it anywhere later.
    
VIP//We will load player's VIP level from database into this variable so we can use it anywhere later.
    
Money//We will load player's money from database into this variable so we can use it anywhere later.
    
Float:posX//We will load player's X position from database into this variable so we can use it anywhere later.
    
Float:posY//We will load player's Y position from database into this variable so we can use it anywhere later.
    
Float:posZ //We will load player's Z from database into this variable so we can use it anywhere later.
}
new 
pInfo[MAX_PLAYERS][PDATA]; //Variable that stores enumerator above 
PHP код:
forward OnAccountCheck(playerid);
public 
OnAccountCheck(playerid)
{
    new 
rowsfields//a variable that will be used to retrieve rows and fields in the database.
    
cache_get_data(rowsfieldsmysql);//let's get the rows and fields from the database.
    
if(rows//if there is row
    
{//then
        
cache_get_field_content(0"Password"pInfo[playerid][Password], mysql129);
        
//we will load player's password into pInfo[playerid][Password] to be used in logging in
        
pInfo[playerid][IDs] = cache_get_field_content_int(0"IDs"); //now let's load player's ID into pInfo[playerid][ID] so we can use it later
        
printf("%s"pInfo[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
        
ShowPlayerDialog(playeriddloginDIALOG_STYLE_INPUT"Login""In order to play, you need to login""Login""Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
    
}
    else 
//if we didn't find any rows from the database, that means, no accounts were found
    
{
        
ShowPlayerDialog(playeriddregisterDIALOG_STYLE_INPUT"Register""In order to play, you need to register.""Register""Quit");
        
//So we show them a dialog register
    
}
    return 
1;

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
dlogin//login dialog
        
{
            if(!
responseKick(playerid); //if they clicked Quit, we will kick them
            
new hpass[129]; //for password hashing
            
new query[100]; // for formatting our query.
            
WP_Hash(hpass129inputtext); //hashing inputtext
            
if(!strcmp(hpasspInfo[playerid][Password])) //remember we have loaded player's password into this variable, pInfo[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
            
//if the hashed password matches with the loaded password from database
                
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1"Name[playerid]);
                
//let's format our query
                //We select all rows in the table that has your name and limit the result to 1
                
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
                
//lets execute the formatted query and when the execution is done, a callback OnAccountLoad will be called
                //You can name the callback however you like
            
}
            else 
//if the hashed password didn't match with the loaded password(pInfo[playerid][Password])
            
{
                
//we tell them that they have inserted a wrong password
                
ShowPlayerDialog(playeriddloginDIALOG_STYLE_INPUT"Login""In order to play, you need to login\nWrong password!""Login""Quit");
            }
        }
        case 
dregister//register dialog
        
{
            if(!
response) return Kick(playerid); //if they clicked Quit, we will kick them
            
if(strlen(inputtext) < 6) return ShowPlayerDialog(playeriddregisterDIALOG_STYLE_INPUT"Register""In order to play, you need to register.\nYour password must be at least 6 characters long!""Register""Quit");
            
//strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
            
new query[300];
            
WP_Hash(pInfo[playerid][Password], 129inputtext); //hashing inputtext
            
mysql_format(mysqlquerysizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0)"Name[playerid], pInfo[playerid][Password], IP[playerid]);
            
//Now let's create a new row and insert player's information in it
            
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid);
            
//let's execute the query
        
}
    }
    return 
1;

Reply
#2

i need it fast. anyone help me?

also this

PHP код:
[02:27:52] [joinALoXsxs has joined the server (
[
02:27:52NULL
[02:27:54hpass"66653529476CC0B4FC1320943A52337281C7F6504F75BCB7FB662054B6DAA8BE4B469DFBD80BD2280AFD6E506972F4D0EFF25B55AA73F4963E2C434B0AEFA578" Password"NULL"
[02:27:56hpass"66653529476CC0B4FC1320943A52337281C7F6504F75BCB7FB662054B6DAA8BE4B469DFBD80BD2280AFD6E506972F4D0EFF25B55AA73F4963E2C434B0AEFA578" Password"NULL"
[02:27:58hpass"66653529476CC0B4FC1320943A52337281C7F6504F75BCB7FB662054B6DAA8BE4B469DFBD80BD2280AFD6E506972F4D0EFF25B55AA73F4963E2C434B0AEFA578" Password"NULL"
[02:27:59hpass"957F28DB29950F4126028B929D6682AC38059060C864846091BC70C473791F98A96F995100D26B3CF34088F317ACB6EED6CFF2F95EACDB688508DC09447DF9DF" Password"NULL"
[02:28:00hpass"B414CD9E72A4D7A5DFBA1DF201265030F815905BFE5250BAABA6EA6AA97517B0D73617EB4D4321331754714486042BEEE68D01F6D2259D23767E4F6E041C22AE" Password"NULL"
[02:28:00hpass"8ACA2602792AEC6F11A67206531FB7D7F0DFF59413145E6973C45001D0087B42D11BC645413AEFF63A42391A39145A591A92200D560195E53B478584FDAE231A" Password"NULL"
[02:28:00hpass"7CC47B24AF0804621B9F81C186AF7D5D2A7746CF92FDEBA19EB150269D171E873E426A642DB0ABBAD5443CA4038966B18C54C1159F1DD9095C44A7BC737CBCB1" Password"NULL"
[02:28:00hpass"FD9CF401E88A1039035CA683F72DEDF83A7C02F2EFF8F04F5E4C4FA9B5DACC778F4208128A6B37A0FA620EA09CA27CD7637BB15418538258C80C87DC74EF35B6" Password"NULL"
[02:28:00hpass"CDD1F00F6FCFE1DDA8AFD7A6E6E710583E8A96F86483C4A0F1E5742210CB034DC941F5A070872EAF593BF9F2ABDDBA679194FA3F4C4A8CBC91883EE9F884A128" Password"NULL"
[02:28:01hpass"480EE1071F98870650B569512E4E24EC1515AA95CEA33114C3029CF12A7DED3497C035FC4C35B1FD19A2341123A0C07FEA3345A6E4605A8BBD45ECFBAA069A6D" Password"NULL"
[02:28:01hpass"7C141F5BF809AA24884C13860DCD20AA56583494536B2E63A0973EA72B2CF4E631230FA9CF42BBDA47C4939F3CB87CD277FDA199E6B08CB7B0FEEDF9D3544BC2" Password"NULL"
[02:28:01hpass"49A5846E94FB69A98E143B7279E5277334B6756B6248C65EFD94BE2BF609B61A8C392558B8F2C7C6713F15C0245E209B538694687DFD4C6202386D9556EEA67D" Password"NULL"
[02:28:02hpass"B68AFBD6DBED608502C5F82D752FFEEB7273E7C96D97EE2B0321AAD19BB223CDE19D8450BB58FB9D67671C1B1A140174D88D533F1441966FBD3F0F60E22B82B6" Password"NULL"
[02:28:02hpass"49A5846E94FB69A98E143B7279E5277334B6756B6248C65EFD94BE2BF609B61A8C392558B8F2C7C6713F15C0245E209B538694687DFD4C6202386D9556EEA67D" Password"NULL"
[02:28:02hpass"0FF532EBD479DDE8B2DFE0FE5364B1842AF94F84A94746CF2783322EFB95C8D6F2EC5155258A297C909E6817DC8C8D38E370C6AD1F1A6B86332AFC14C51EB0A7" Password"NULL"
[02:28:03hpass"19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3" Password"NULL"
[02:28:04] [partALoXsxs has left the server (0:2)
[
02:28:04hpass"19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3" Password"NULL" 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)