12.11.2013, 16:08
alright, back again, with more mysql problems, im currently working on fixing my mysql login/register system, atm, everything works perfectly, except, login, upon login, it will detect your username, and that your register'd, however, it allows you to use whatever password you want to login, and i just dont understand why, here is the mysql log, as well as the login code, it all looks fine to me, i really dont see why it doesnt kick players upon incorrect password:
Login player code:
Код:
[11:46:32] --------------------------- [11:46:32] MySQL Debugging activated (11/12/13) [11:46:32] --------------------------- [11:46:32] [11:50:21] >> mysql_query( Connection handle: 1 ) [11:50:21] CMySQLHandler::Query(SELECT `Username` FROM `Users` WHERE `Username` = 'logoster' LIMIT 1;) - Successfully executed. [11:50:21] >> mysql_store_result( Connection handle: 1 ) [11:50:21] CMySQLHandler::StoreResult() - Result was stored. [11:50:21] >> mysql_num_rows( Connection handle: 1 ) [11:50:21] CMySQLHandler::NumRows() - Returned 1 row(s) [11:50:21] >> mysql_free_result( Connection handle: 1 ) [11:50:21] CMySQLHandler::FreeResult() - Result was successfully free'd.
pawn Код:
stock LoginPlayer(playerid,const password[])
{
new escape[MAX_PLAYER_NAME], Query[128], hash[129];
mysql_real_escape_string(GetName(playerid), escape);
format(hash, sizeof(hash), "%s%s", PInfo[playerid][Salt], password);
WP_Hash(hash, 129, hash);
format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s'",escape);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
if(strcmp(hash, PInfo[playerid][Password]))
{
SendClientMessage(playerid,COLOR_RED,"Wrong password!");
Kick(playerid);
}
else
{
SendClientMessage(playerid,COLOR_LIME,"You have been logged in!");
LoadStats(playerid);
}
}
mysql_free_result();
return 1;
}