26.06.2013, 07:49
Hello.
Does anyone know why this code doesn't work?
Everytime I try to log in it tells me I got the wrong password.
Does anyone know why this code doesn't work?
pawn Код:
stock PlayerRegister(playerid, password)
{
new str[128];
format(str,sizeof(str),"INSERT INTO users (username, password) VALUES ('%s', md5('%s'))", pName(playerid), password);
mysql_query(str);
format(str, sizeof(str),"You have registered as %s on %s.\nPlease confirm your password:",pName(playerid),SERVERNAME);
ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login",str,"Login","Cancel");
}
stock PlayerLogin(playerid, password)
{
new str[128];
format(str, sizeof(str),"SELECT * FROM users WHERE username = '%s' AND password = md5('%s')",pName(playerid),password);
mysql_query(str);
mysql_store_result();
if(!mysql_num_rows())
{
SendInfoMessage(playerid,"Wrong {a9c4e4}password{ffffff}! Kicked due to security reasons!");
Kick(playerid);
mysql_free_result();
return 1;
}
else
{
SendInfoMessage(playerid,"Successfully logged in. Welcome back!");
mysql_free_result();
return 1;
}
}