Login System error - 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: Login System error (
/showthread.php?tid=659000)
Login System error -
Score - 19.09.2018
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:
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;
}
Re: Login System error -
Score - 19.09.2018
Fixed, dammit im so dumb.
Had to change
PHP код:
cache_get_value_name(0, "Password", PlayerInfo[playerid][Password]);
To:
PHP код:
cache_get_value_name(0, "Password", PlayerInfo[playerid][Password], 129);
Re: Login System error -
v1k1nG - 20.09.2018
Please Salt the passwords