19.09.2018, 21:21
Hello, i'm having an error with my login/register system.
It's has something to do with the password, because even if i type the wrong password it still logs me in...
Here is the codes that have to do with login:
It's has something to do with the password, because even if i type the wrong password it still logs me in...
Here is the codes that have to do with login:
PHP код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows)
{
cache_get_value_name(0, "PASS", PlayerInfo[playerid][Password]);
cache_get_value_name_int(0, "ID", PlayerInfo[playerid][ID]);
printf("%s", PlayerInfo[playerid][Password]);
Dialog_Show(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Welcome to Roleplay. Type your password below to login to your account.", "Login", "Exit");
}
else
{
Dialog_Show(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Welcome to Roleplay. In order to play you will need to register an account. Type a decent password below to continue.", "Register", "Exit");
}
return 1;
}
PHP код:
Dialog:DIALOG_LOGIN(playerid, response, listitem, inputtext[])
{
if(!response) Kick(playerid);
new hpass[129];
new query[100];
WP_Hash(hpass, 129, inputtext);
if(!strcmp(hpass, PlayerInfo[playerid][Password]))
{
mysql_format(Database, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(Database, query, "OnAccountLoad", "i", playerid);
}
else
{
Dialog_Show(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FF0000}Wrong Password!\n{FFFFFF}Input your correct password to continue!", "Login", "Exit");
}
return 1;
}