Error mysql Login Pass -
arlindi - 10.04.2015
PHP код:
forward MySQL_Login(playerid);
public MySQL_Login(playerid)
{
cache_get_field_content(0,"Username", pInfo[playerid][pUsername]);
cache_get_field_content(0, "Password",pInfo[playerid][pPassword]);
pInfo[playerid][pXP] = cache_get_field_content_int(0, "XP");
pInfo[playerid][pKills] = cache_get_field_content_int(0, "Kills");
pInfo[playerid][pDeaths] = cache_get_field_content_int(0, "Deaths");
pInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank");
pInfo[playerid][pEvac] = cache_get_field_content_int(0, "Evac");
pInfo[playerid][pAdminLevel] = cache_get_field_content_int(0, "AdminLevel");
pInfo[playerid][pVipLevel] = cache_get_field_content_int(0, "VipLevel");
pInfo[playerid][pHour] = cache_get_field_content_int(0, "Hour");
pInfo[playerid][pMin] = cache_get_field_content_int(0, "Min");
pInfo[playerid][pSec] = cache_get_field_content_int(0, "Sec");
pInfo[playerid][pMapsPlayed] = cache_get_field_content_int(0, "MapsPlayed");
pInfo[playerid][pCoins] = cache_get_field_content_int(0, "Coins");
pInfo[playerid][pLogged] = 1;
CheckBan(playerid);
playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
return 1;
}
Hello here is my problem
The password hen register he got save as hashed
I want when use it to be uset also login as hashed because i cant find the password in this line
cache_get_field_content(0, "Password",pInfo[playerid][pPassword]);
Here is and the Register
PHP код:
case DIALOG_REGISTER:
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 128)
{
new string[128];
SendClientMessage(playerid, -1, ""chat" You must insert a password between 1-128 characters!");
format(string,sizeof(string),""chat" Hello %s to "NAME"",PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD ,string,""chat" Welcome to "NAME" you'll be forced to register please click register!","Register","Quit");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 128)
{
new escpass[100];
mysql_real_escape_string(inputtext, escpass);
MySQL_Register(playerid, escpass);
TextDrawHideForPlayer(playerid, login0);
TextDrawHideForPlayer(playerid, login1);
TextDrawHideForPlayer(playerid, login2);
TextDrawHideForPlayer(playerid, login3);
}
}
if(!response)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must register to play at "NAME"","Close","");
Kick(playerid);
}
}
Re: Error mysql Login Pass -
arlindi - 10.04.2015
AnyOne Please
I want to get login as hashed
When account registered
He got register as hashed password
But
when the login is not ned password as hashed
Re: Error mysql Login Pass -
arlindi - 10.04.2015
PHP код:
case DIALOG_LOGIN:
{
if(!response)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must login to play at "NAME"","Close","");
Kick(playerid);
}
if(response)
{
new query[256], pname[24];
GetPlayerName(playerid, pname, 24);
mysql_format(mysql, query, sizeof(query), "SELECT `Username` FROM `users` WHERE Username = '%s' AND Password = SHA1('%s')", pname, inputtext);
mysql_tquery(mysql, query, "","");
new numrows = cache_num_rows();
if(numrows == 1) Login_stock(playerid);
TextDrawHideForPlayer(playerid, login0);
TextDrawHideForPlayer(playerid, login1);
TextDrawHideForPlayer(playerid, login2);
TextDrawHideForPlayer(playerid, login3);
if(!numrows)
{
new string[256];
format(string,sizeof(string),""chat" Welcome back %s to "NAME"",PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,string,""chat" Our system have detected your username registered please login","Login","Quit");
}
}
}
Here is and DIALOG_LOGIN
Can you please tell mee what is wrong here?
Re: Error mysql Login Pass -
arlindi - 11.04.2015
Hmm Anyone ?
AW: Error mysql Login Pass -
Mencent - 11.04.2015
Hello!
Can you share your MySQL_Register function?
Mencent
Re: Error mysql Login Pass -
arlindi - 11.04.2015
PHP код:
stock MySQL_Register(playerid, passwordstring[])
{
new Query[256],IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
strcat(Query,"INSERT INTO `users` (`Username`,`Password`,`pXP`,`pKills`,`pDeaths`,`pRank`, `pLevel`,`pAdminLevel`");
strcat(Query,",`pVipLevel`, `pHour`, `pMin`, `pSec`, `pMapsPlayed`, `pCoins`, `pIP`) VALUES ('%s', SHA1('%s'),1,0,0,0,0,0,0,0,0,0,0,0,'%s')");
mysql_format(mysql, Query,sizeof(Query),Query,PlayerName(playerid),passwordstring,IP);
mysql_tquery(mysql, Query);
playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
pInfo[playerid][pLogged] = 1;
CheckBan(playerid);
return 1;
}
Done!
Re: Error mysql Login Pass -
arlindi - 11.04.2015
Am soo verry sorry for this bump! but please i am need to fix this
Mencent can you fix this please ?
AW: Error mysql Login Pass -
Mencent - 11.04.2015
Write it so, work this?
PHP код:
case DIALOG_LOGIN:
{
if(!response)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must login to play at "NAME"","Close","");
Kick(playerid);
}
if(response)
{
new query[256], pname[24];
GetPlayerName(playerid, pname, 24);
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE Username = '%s' AND Password = SHA1('%s')", pname, inputtext);
mysql_tquery(mysql, query, "MySQL_Login","i",playerid);
TextDrawHideForPlayer(playerid, login0);
TextDrawHideForPlayer(playerid, login1);
TextDrawHideForPlayer(playerid, login2);
TextDrawHideForPlayer(playerid, login3);
}
}
forward MySQL_Login(playerid);
public MySQL_Login(playerid)
{
if(!cache_num_rows())
{
new string[256];
format(string,sizeof(string),""chat" Welcome back %s to "NAME"",PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,string,""chat" Our system have detected your username registered please login","Login","Quit");
}
cache_get_field_content(0,"Username", pInfo[playerid][pUsername],mysql,MAX_PLAYER_NAME);
cache_get_field_content(0, "Password",pInfo[playerid][pPassword],mysql,);//AFTER THE "," HAVE TO PUT IN THE LENGTH OF pPassword!!!
printf("Password: %s",pInfo[playerid][pPassword]);
pInfo[playerid][pXP] = cache_get_field_content_int(0, "XP");
pInfo[playerid][pKills] = cache_get_field_content_int(0, "Kills");
pInfo[playerid][pDeaths] = cache_get_field_content_int(0, "Deaths");
pInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank");
pInfo[playerid][pEvac] = cache_get_field_content_int(0, "Evac");
pInfo[playerid][pAdminLevel] = cache_get_field_content_int(0, "AdminLevel");
pInfo[playerid][pVipLevel] = cache_get_field_content_int(0, "VipLevel");
pInfo[playerid][pHour] = cache_get_field_content_int(0, "Hour");
pInfo[playerid][pMin] = cache_get_field_content_int(0, "Min");
pInfo[playerid][pSec] = cache_get_field_content_int(0, "Sec");
pInfo[playerid][pMapsPlayed] = cache_get_field_content_int(0, "MapsPlayed");
pInfo[playerid][pCoins] = cache_get_field_content_int(0, "Coins");
pInfo[playerid][pLogged] = 1;
CheckBan(playerid);
playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
return 1;
}
Mencent
Re: Error mysql Login Pass -
arlindi - 11.04.2015
PHP код:
stock Login_stock(playerid)
{
new Query[256];
mysql_format(mysql,Query, sizeof(Query), "SELECT * FROM users WHERE Username = '%e'", PlayerName(playerid));
mysql_tquery(mysql, Query, "MySQL_Login","i",playerid);
}
What about this i have and this also
Have this any problem ?
And 1 question: In your code if i use the password wrong i will not get again the password dialog to put it
and the textdraw will be hide before i use my succses password
AW: Error mysql Login Pass -
Mencent - 11.04.2015
Delete this out of your script:
PHP код:
stock Login_stock(playerid)
{
new Query[256];
mysql_format(mysql,Query, sizeof(Query), "SELECT * FROM users WHERE Username = '%e'", PlayerName(playerid));
mysql_tquery(mysql, Query, "MySQL_Login","i",playerid);
}
And take my code. Well, work this now?
Mencent