So I've been trying to make a Login/Register system using MySQL R35.
The password and the username are saved correctly, but when I try to login it kicks me even if I inserted the correct password... Help?
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) > 3 && strlen(inputtext) < 20)
{
new Name[MAX_PLAYER_NAME],string[128];
LoggedIn[playerid] = 1;
GetPlayerName(playerid,Name,sizeof(Name));
format(string,sizeof(string),"INSERT INTO `users` (`Username`, `Password`) VALUES('%s', ('%s'))",Name,inputtext);
mysql_query(MySQL,string);
new text[128];
format(text,sizeof(text),"Welcome %s! You are now registered",Name);
SendClientMessage(playerid,COLOR_YELLOW,text);
printf("%s has registered.",Name);
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"Your password is too short or too long!");
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
new string[128],password[128],Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
format(string,sizeof(string),"SELECT `Password` FROM `users` WHERE `Username` = '%s'",Name);
mysql_query(MySQL,string);
cache_get_query_string(password);
if(strcmp(inputtext,password,false) == 0)
{
new text[128];
format(text,sizeof(text),"Welcome back %s! You are now logged in",Name);
SendClientMessage(playerid,COLOR_YELLOW,text);
printf("%s has logged in.",Name);
LoggedIn[playerid] = 1;
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
}
else
{
SendClientMessage(playerid,COLOR_SYSTEM,"WRONG PASSWORD!");
Kick(playerid);
}
}
}
return 1;
}
pawn Код:
new text[128];
format(text,sizeof(text),"Welcome back %s! You are now logged in",Name);
SendClientMessage(playerid,COLOR_YELLOW,text);
printf("%s has logged in.",Name);
LoggedIn[playerid] = 1;
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);