Mysql Password Fail -
SanAndreasVille - 23.04.2012
I have a problem i can register a account without a password how can i make a min lengh of passwort of 4 chars ?
here is the script @ register
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 14600)
{
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel");
SendClientMessage(playerid, 0xF60000AA, "Please enter a password");
}
mysql_real_escape_string(inputtext, escpass);
WP_Hash(largestring, sizeof(largestring), escpass);
GetPlayerIp(playerid, PIP, 50);
format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`user`, `password`, `kills`, `deaths`, `score`, `money`, `IP`, `adminlvl`) VALUES ('%s', '%s', 0, 0, 0, 0, '%s', 0)", escpname(playerid), largestring, PIP);
mysql_query(Query);
GameTextForPlayer(playerid, "~g~Registered", 2000, 3);
SendClientMessage(playerid, 0x0000D9AA, "Registered and Logged into your account!");
SetPVarInt(playerid, "Logged", 1);
}
}
if(dialogid == 15000)
{
if(response)
{
WP_Hash(largestring, sizeof(largestring), inputtext);
format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s' LIMIT 1", escpname(playerid), largestring);
mysql_query(Query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
SendClientMessage(playerid, 0xF60000AA, "Invalid password!");
SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1);
ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel");
if(GetPVarInt(playerid, "WrongPass") == 3)
{
SendClientMessage(playerid, 0xF60000AA, "Max password tries exceeded!!");
Kick(playerid);
}
mysql_free_result();
}
else if(rows > 0)
{
if(mysql_fetch_row(line))
{
new data[3][55];
new data2[5];
sscanf(line, "p<|>s[50]s[300]dddds[50]ds[100]", data[0], largestring, data2[0], data2[1], data2[2], data2[3], data[2], data2[4], estring);
stringempty(estring);
stringempty(largestring);
SetPVarInt(playerid, "Kills", data2[0]);
SetPVarInt(playerid, "Logged", 1);
SetPVarInt(playerid, "Deaths", data2[1]);
SetPlayerScore(playerid, data2[2]);
GivePlayerMoney(playerid, data2[3]);
SetPVarInt(playerid, "AdminLevel", data2[4]);
SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
mysql_free_result();
GetPlayerIp(playerid, PIP, 18);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET IP = '%s' WHERE user='%s'", PIP, escpname(playerid));
mysql_query(Query);
}
}
}
}
return 1;
}
Re: Mysql Password Fail -
Roel - 23.04.2012
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 14600)
{
if(response)
{
if(!strlen(inputtext) && strlen(inputtext) >= 4)
{
ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel");
return SendClientMessage(playerid, 0xF60000AA, "Please enter a password with a minimun size of 4 characters.");
}
mysql_real_escape_string(inputtext, escpass);
WP_Hash(largestring, sizeof(largestring), escpass);
GetPlayerIp(playerid, PIP, 50);
format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`user`, `password`, `kills`, `deaths`, `score`, `money`, `IP`, `adminlvl`) VALUES ('%s', '%s', 0, 0, 0, 0, '%s', 0)", escpname(playerid), largestring, PIP);
mysql_query(Query);
GameTextForPlayer(playerid, "~g~Registered", 2000, 3);
SendClientMessage(playerid, 0x0000D9AA, "Registered and Logged into your account!");
SetPVarInt(playerid, "Logged", 1);
}
}
if(dialogid == 15000)
{
if(response)
{
WP_Hash(largestring, sizeof(largestring), inputtext);
format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s' LIMIT 1", escpname(playerid), largestring);
mysql_query(Query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
SendClientMessage(playerid, 0xF60000AA, "Invalid password!");
SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1);
ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel");
if(GetPVarInt(playerid, "WrongPass") == 3)
{
SendClientMessage(playerid, 0xF60000AA, "Max password tries exceeded!!");
Kick(playerid);
}
mysql_free_result();
}
else if(rows > 0)
{
if(mysql_fetch_row(line))
{
new data[3][55];
new data2[5];
sscanf(line, "p<|>s[50]s[300]dddds[50]ds[100]", data[0], largestring, data2[0], data2[1], data2[2], data2[3], data[2], data2[4], estring);
stringempty(estring);
stringempty(largestring);
SetPVarInt(playerid, "Kills", data2[0]);
SetPVarInt(playerid, "Logged", 1);
SetPVarInt(playerid, "Deaths", data2[1]);
SetPlayerScore(playerid, data2[2]);
GivePlayerMoney(playerid, data2[3]);
SetPVarInt(playerid, "AdminLevel", data2[4]);
SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
mysql_free_result();
GetPlayerIp(playerid, PIP, 18);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET IP = '%s' WHERE user='%s'", PIP, escpname(playerid));
mysql_query(Query);
}
}
}
}
return 1;
}
Re: Mysql Password Fail -
Hiddos - 23.04.2012
Might want to recheck that if-statement, Roel
Re: Mysql Password Fail -
Elysian` - 23.04.2012
Код:
if(strlen(inputtext) <= 4)
Re: Mysql Password Fail -
Roel - 23.04.2012
if(strlen(inputtext) >= 4)
You mean that this is also enough?
Ow shit yea, I forgot the ! ;P
Re: Mysql Password Fail -
SanAndreasVille - 24.04.2012
when i press enter ,doesnt show "Please enter a password with a minimun size of 4 characters.");"
the account is registered without pw the pw ist "enter" without number etc.
what is wrong?