public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if (dialogid == login) { new query[256]; format(query,sizeof(query),"SELECT `senha` FROM `usuario` WHERE `login` = '%s'",PlayerName(playerid)); mysql_query(query); mysql_store_result(); PlayerStatistics[playerid][PASSWORD] = mysql_fetch_int(); if(strcmp( inputtext, PlayerStatistics[ playerid ][ PASSWORD ], true ) == 0 ) { Logged[playerid]==1; printf("[Login]: O usuario `%s` fez login com sucesso!",PlayerName(playerid)); SendClientMessage(playerid, COR_INFO, "You've been succesfully authed."); new welcome[256]; format(welcome,sizeof(welcome),"Welcome back '%s' ",PlayerName(playerid)); SendClientMessage(playerid, COR_INFO, welcome); } else { new welcome[256]; format(welcome,sizeof(welcome),"Bad, bad password. Password entered: '%s' ",inputtext); SendClientMessage(playerid, COR_BRANCO, welcome); SendClientMessage( playerid, COR_BRANCO, "Bad, bad password. To avoid lammers you will be automatically disconnected." ); SetTimer("kicklogin", 10000, false); } return 0; } return 0; } |
[13:16:25] --------------------------- [13:16:25] MySQL Debugging activated (04/21/10) [13:16:25] --------------------------- [13:16:25] [13:16:56] >> mysql_query( Connection handle: 1 ) [13:16:56] CMySQLHandler::Query(SELECT `login` FROM `usuario` WHERE `login` = 'Lucca_Xavier') - Successfully executed. [13:16:56] >> mysql_store_result( Connection handle: 1 ) [13:16:56] CMySQLHandler::StoreResult() - Result was stored. [13:16:56] >> mysql_num_rows( Connection handle: 1 ) [13:16:56] CMySQLHandler::NumRows() - Returned 1 rows(s) [13:16:59] >> mysql_query( Connection handle: 1 ) [13:16:59] CMySQLHandler::Query(SELECT `senha` FROM `usuario` WHERE `login` = 'Lucca_Xavier') - Successfully executed. [13:16:59] >> mysql_store_result( Connection handle: 1 ) [13:16:59] CMySQLHandler::StoreResult() - Result was stored. [13:16:59] >> mysql_fetch_int( Connection handle: 1 ) [13:16:59] CMySQLHandler::FetchRow() - Return: MYPASSWORD! |
Originally Posted by kariok
how can i use the password as a string instead of an integer value?!
|
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == login)
{
new query[ 128 ], EscapedPass[ 128 ];
mysql_real_escape_string( inputtext, EscapedPass );
format(query,sizeof(query), "SELECT * FROM `usuario` WHERE `login` = '%s' AND `password` = '%s'", PlayerName( playerid ), EscapedPass );
mysql_query( query );
mysql_store_result();
if( mysql_num_rows() >= 1 )
{
// Success.
}
else
{
// Failed.
}
mysql_free_result();
}
return 1;
}