06.09.2013, 17:08
What about this? I tested it briefly and it seems to work pretty fine, I'd still like to hear others' opinions.
PHP код:
case 2: // Login
{
new name[MAX_PLAYER_NAME+1], string[128];
GetPlayerName(playerid, name, sizeof(name));
//if(CheckPassword(name, inputtext) >= 1)
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'", name, inputtext);
mysql_function_query(dbHandle, string, true, "CheckPassword", "is", playerid, name);
}
PHP код:
forward CheckPassword(playerid, name[]);
public CheckPassword(playerid, name[])
{
new rows, fields, string[128];
cache_get_data(rows, fields, dbHandle);
if(rows >= 1)
{
SendClientMessage(playerid, COLOR_WHITE, "[SUCCESS] You have successfully logged in!");
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s'", name);
mysql_function_query(dbHandle, string, true, "GetStats", "d", playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[Error] Wrong password!");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Wrong password, enter the correct one!", "Submit", "Cancel");
}
return 1;
}