MySQL <> login with any password
#1

Hey,
i have a mysql code problem. If i try to connect on my server and type my password for my account, and if i type any password like "1" or "dfnjese" (not my password) it will be work. What is flae in my code?
i use md5 to secure my passwords.

Код:
		case DIALOG_LOGIN:
		{
			if(response)
			{
				if(strlen(inputtext) == 0)
				{
					ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Bloodz {FFFFFF}n {00FF00}Cripz {FFFFFF}- {FFFF00}Login", "{FFFFFF}Es freut uns dich wieder auf unserem Server zu sehen!\nBitte gebe dein {00FF00}Passwort {FFFFFF}ein um dich in deinem Account einzuloggen", "Einloggen", "Abbrechen");
					return 1;
				}
				else
				{
					new SpielerName[MAX_PLAYER_NAME];
					GetPlayerName(playerid, SpielerName, MAX_PLAYER_NAME);
                    if(!strcmp(MD5_Hash(inputtext), mysql_ReturnPasswort(SpielerName), true))
					{
						SetPVarInt(playerid,"Eingeloggt",1);
						LoadPlayer(playerid);
						SendClientMessage(playerid, lightgreen, "{FFFF00}[SERVER] {FFFFFF}Du bist nun eingeloggt. Viel spaЯ auf dem Server.");
						SendClientMessage(playerid, lightgreen, "{FFFF00}[SERVER] {FFFFFF}Bitte wдhle eine Gang aus.");
						return 1;
					}
                    else
					{
						ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Bloodz {FFFFFF}n {00FF00}Cripz {FFFFFF}- {FFFF00}Login", "{00FF00}Password flasch!\n{FFFFFF}Bitte gebe dein {00FF00}Passwort {FFFFFF}ein um dich in deinem Account einzuloggen", "Einloggen", "Abbrechen");
						return 1;
					}
				}
			}
			else
			{
				SendClientMessage(playerid, lightgreen, "{FFFF00}[SERVER] {FFFFFF}Du brauchst leider ein Account um auf dem Server spielen zu kцnnen.");
				Kick(playerid);
			}
		}
Код:
stock mysql_ReturnPasswort(Name[])
{
    new query[130], Get[130];
    mysql_real_escape_string(Name, Name);
    format(query, 128, "SELECT md5(`Password`) FROM `Accounts` WHERE `Name` = '%s'", Name);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
}
Код:
stock CreateAccount(playerid, pass[])
{
    new query[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name,Name);
    mysql_real_escape_string(pass,pass);
    format(query, sizeof(query), "INSERT INTO `Accounts` (`Name`, `Password`) VALUES ('%s', md5('%s'))", Name, pass);
    mysql_query(query);
    return true;
}
hope for help
Reply


Messages In This Thread
MySQL <> login with any password - by s3rserii - 12.09.2012, 14:48
AW: MySQL <> login with any password - by s3rserii - 12.09.2012, 17:32
Re: MySQL <> login with any password - by [MG]Dimi - 12.09.2012, 18:22
AW: Re: MySQL <> login with any password - by s3rserii - 12.09.2012, 18:24
Re: MySQL <> login with any password - by [HiC]TheKiller - 13.09.2012, 05:27
AW: MySQL <> login with any password - by s3rserii - 13.09.2012, 07:18
Re: AW: MySQL <> login with any password - by [HiC]TheKiller - 13.09.2012, 07:25
AW: MySQL <> login with any password - by s3rserii - 13.09.2012, 07:31
Re: MySQL <> login with any password - by [HiC]TheKiller - 13.09.2012, 07:39
AW: MySQL <> login with any password - by s3rserii - 13.09.2012, 08:12

Forum Jump:


Users browsing this thread: 1 Guest(s)