Help in Register
#1

Hello,

i Have A problem With Register And Login System When I Post Picture Some Guys Not understanding i Create Small ******* Video I Hope This video is Understand U and U Will help me

https://www.youtube.com/watch?v=hh1_...ature=*********
Reply
#2

Are you encrypting passwords when they register?

If they are, are you comparing the encrypted password with the one inside your database?

The only reason it's saying incorrect password is because it literally is an incorrect password, you could be encrypting the password when they register, but if you're just comparing plain text to an encrypted password, it isn't going to be the same.
Reply
#3

But i Type The Same Password
Reply
#4

Drop here your code
Reply
#5

Quote:
Originally Posted by coool
Посмотреть сообщение
Drop here your code
Код:
public DisplayDialogForPlayer(playerid, dialogid)
{
    switch(dialogid)
    {
        case 1:
        {
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"{1B8AE4}Login","{FFFFFF}Welcome to the {1B8AE4}Life of Flying\n\n{FFFFFF}This account is {1B8AE4}registered. {FFFFFF}To gain access, input your password below","Login","Quit");
        }
        case 2:
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{1B8AE4}Registration","{FFFFFF}Welcome to the {1B8AE4}Life of Flying\n\n{FFFFFF}Please {1B8AE4}register {FFFFFF}an account by typing a password below.","Register","Quit");
        }
Код:
public PlayerLogin(playerid,password[])
{
	mysql_reconnect();
	new EscPass[128], EscName[128], Query[128];
	mysql_real_escape_string(PlayerName(playerid), EscName);
	mysql_real_escape_string(password, EscPass);
	format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", EscName, EscPass);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows() > 0)
	{ // player logged in.
		new line[1250];
		if(mysql_fetch_row(line)) //Fetches the line
  		{
  		    new string2[128];
    		new data[11][128]; //The data strings
      		new data2[56]; //The data variables
      		//new Float:data3[5]; //The data floats
      		sscanf(line, "p<|>s[128]s[128]ds[128]s[128]ddddddddddddddsds[128]ds[128]dddddddddddddddddddds[128]s[128]ds[128]ddddddddds[128]ddddddddd", data[0], data[1], data2[0], data[2], data[3], data2[1], data2[2], data2[3], data2[4], data2[5], data2[6], data2[7], data2[8], data2[9], data2[10], data2[11], data2[12], data2[13], data2[14], data[4], data2[15], data[5], data2[16], data[6], data2[17], data2[18], data2[19],
			  data2[20], data2[21], data2[22], data2[23], data2[24], data2[25], data2[26], data2[27], data2[28], data2[29], data2[30], data2[31], data2[32], data2[33], data2[34], data2[35], data2[36], data[7], data[8], data2[37], data[9], data2[38], data2[39], data2[40], data2[41],data2[42],data2[43],data2[44],data2[45],data2[46],data[10],data2[47], data2[48],data2[49],data2[50],data2[51],data2[52],data2[53],data2[54],data2[55]); //Splits the line with sscanf
			format(string2, sizeof(string2), "%s", data[1]); //PASSWORD
			strmid(PInfo[playerid][Password], string2, 0, strlen(string2), 128); //PASSWORD
			PInfo[playerid][AdminLevel] = data2[0];
			format(string2, sizeof(string2), "%s", data[3]); //last login date+time
			strmid(PInfo[playerid][LastLogin], string2, 0, strlen(string2), 128); //last login date+time
			PInfo[playerid][Banned] = data2[1];
			PInfo[playerid][Money] = data2[2];
			PInfo[playerid][AT400F] = data2[3];
			PInfo[playerid][STUNTF] = data2[4];
			PInfo[playerid][HELIF] = data2[5];
			PInfo[playerid][CARGOF] = data2[6];
			PInfo[playerid][MILITARYF] = data2[7];
			PInfo[playerid][SHAMALF] = data2[8];
			PInfo[playerid][DODOF] = data2[9];
			PInfo[playerid][SKIMMERF] = data2[10];
			PInfo[playerid][Muted] = data2[11];
			PInfo[playerid][HoursPlayed] = data2[12];
			PInfo[playerid][MinsPlayed] = data2[13];
			PInfo[playerid][Warning1] = data2[14];
			format(string2, sizeof(string2), "%s", data[4]);
			strmid(PInfo[playerid][Reason1], string2, 0, strlen(string2), 128);
			PInfo[playerid][Warning2] = data2[15];
			format(string2, sizeof(string2), "%s", data[5]);
			strmid(PInfo[playerid][Reason2], string2, 0, strlen(string2), 128);
			PInfo[playerid][Warning3] = data2[16];
			format(string2, sizeof(string2), "%s", data[6]);
			strmid(PInfo[playerid][Reason3], string2, 0, strlen(string2), 128);
			PInfo[playerid][TotalJobs] = data2[17];
			PInfo[playerid][TotalScore] = data2[18];
			PInfo[playerid][ANDROF] = data2[19];
			PInfo[playerid][BEAGLEF] = data2[20];
			PInfo[playerid][CROPDUSTERF] = data2[21];
			PInfo[playerid][HYDRAF] = data2[22];
			PInfo[playerid][NEVADAF] = data2[23];
			PInfo[playerid][RUSTLERF] = data2[24];
			PInfo[playerid][CARGOBOBF] = data2[25];
			PInfo[playerid][HUNTERF] = data2[26];
			PInfo[playerid][LEVIATHANF] = data2[27];
			PInfo[playerid][MAVERICKF] = data2[28];
			PInfo[playerid][NMAVERICKF] = data2[29];
			PInfo[playerid][PMAVERICKF] = data2[30];
			PInfo[playerid][RAINDANCEF] = data2[31];
			PInfo[playerid][SEASPARROWF] = data2[32];
			PInfo[playerid][SPARROWF] = data2[33];
			PInfo[playerid][Online] = data2[34];
			PInfo[playerid][EarntFromWorking] = data2[35];
			PInfo[playerid][FlightsCompleted] = data2[36];
			format(string2, sizeof(string2), "%s", data[7]);
			strmid(PInfo[playerid][RegisterDate], string2, 0, strlen(string2), 128);
			format(string2, sizeof(string2), "%s", data[8]);
			strmid(PInfo[playerid][Callsign], string2, 0, strlen(string2), 64);
			PInfo[playerid][CallsignSet] = data2[37];
			format(string2, sizeof(string2), "%s", data[9]);
			strmid(PInfo[playerid][Email], string2, 0, strlen(string2), 256);
			PInfo[playerid][MemberID] = data2[38];
			PInfo[playerid][Airline] = data2[39];
			PInfo[playerid][AirlineRank] = data2[40];
			PInfo[playerid][EarntForAirline] = data2[41];
			PInfo[playerid][House1] = data2[42];
			PInfo[playerid][House2] = data2[43];
			PInfo[playerid][FlownDistance] = data2[44];
			PInfo[playerid][AirlineFlights] = data2[45];
			PInfo[playerid][Vip] = data2[46];
			format(string2, sizeof(string2), "%s", data[10]); //last login date+time
			strmid(PInfo[playerid][VIPColour], string2, 0, strlen(string2), 128); //last login date+time
			PInfo[playerid][Tickets] = data2[47];
			PInfo[playerid][sSpawn] = data2[48];
			PInfo[playerid][sSkin] = data2[49];
			PInfo[playerid][sPM] = data2[50];
			PInfo[playerid][sVIPSounds] = data2[51];
			PInfo[playerid][OwnedSkin] = data2[52];
			PInfo[playerid][sGlobalSounds] = data2[53];
			PInfo[playerid][sConnectionMessages] = data2[54];
			PInfo[playerid][sAutoWork] = data2[55];
            mysql_free_result();
        }
        new string[250];
	    //LoadPlayer(playerid);
	    mysql_free_result();
	    SessionStatus[playerid] = 2; //Logged in successfully. Show disconnect messages
		//if(PInfo[playerid][Banned] == 1) { CheckBanned(playerid); }
		PlayerLogged[playerid] = 1;
		SendClientMessage(playerid, COLOR_GREEN, "You have successfully been logged in.");
		new plrIP[16];
		GetPlayerIp(playerid, plrIP, sizeof(plrIP));
		GivePlayerMoney(playerid, PInfo[playerid][Money]);
		strmid(PInfo[playerid][IP], plrIP, 0, strlen(plrIP), 255);
		if(JustRegistered[playerid] == 0)
		{
			new login[156];
			format(login, sizeof(login), "{1B8AE4}%s (%d) {FFFFFF}has logged into the server.", PlayerName(playerid), playerid);
			for(new i = 0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
		    		if(PInfo[i][sConnectionMessages] == 0)
		    		{
						SendClientMessage(i, COLOR_YELLOW, login);
					}
				}
			}
		}
		if(PInfo[playerid][AdminLevel] > 0) { format(string, sizeof(string), "You have authorized as a level %d administrator.", PInfo[playerid][AdminLevel]); SendClientMessage(playerid, COLOR_SECURITY, string); }
		if(JustRegistered[playerid] == 0) { format(string, sizeof(string), "{FFFFFF}Welcome back to the Life of Flying, {1B8AE4}%s {FFFFFF}- {1B8AE4}[Last session: %s | %s]", PlayerName(playerid), PInfo[playerid][IP], PInfo[playerid][LastLogin]); SendClientMessage(playerid, COLOR_MESSAGE, string); }
		UpdateScore(playerid);
		PInfo[playerid][Online] = 1;
		YourOnline(playerid);
		CanAdvertiseAgain[playerid] = 1;
		if(PInfo[playerid][Airline] > 0)
		{
		    format(string,sizeof(string),"AMOTD: %s | Set by: %s", AInfo[PInfo[playerid][Airline]][aMotd], AInfo[PInfo[playerid][Airline]][aMotdSetBy]);
		    SendClientMessage(playerid, COLOR_YELLOW, string);
		}
		new motdstring[256];
		format(motdstring,sizeof(motdstring),"MOTD: %s | Set by: %s", ServerMOTD, ServerMOTDSetBy);
		SendClientMessage(playerid, COLOR_YELLOW, motdstring);
		if(PInfo[playerid][CallsignSet] == 0)
		{
			new msg[64];
			format(msg,sizeof(msg),"LoF");
			strmid(PInfo[playerid][Callsign], msg, 0, strlen(msg), 64);
			PInfo[playerid][CallsignSet] = 1;
		}

	}
	else
	{ // player incorrect password.
		SendClientMessage(playerid, COLOR_SECURITY, "Invalid password. Please try again, or request a password reset on the forums.");
		DisplayDialogForPlayer(playerid, 1);
  		mysql_free_result();
	}
}
Код:
public OnPlayerRequestClass(playerid, classid)
{
	TogglePlayerControllable(playerid, false);
	SetPlayerPos(playerid,1933.6263,-2399.9102,1201.7321);
	SetPlayerCameraPos(playerid, 1931.7674, -2417.5302, 1205.6908);
	SetPlayerCameraLookAt(playerid, 1931.7674, -2417.5202, 1200.6908);
    if(PlayerLogged[playerid] == 0)
	{
		mysql_reconnect();
		new	Query[90], EscName[MAX_PLAYER_NAME];
		mysql_real_escape_string(PlayerName(playerid), EscName);
		format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s'", EscName);
		mysql_query(Query);
		mysql_store_result();
		if(mysql_num_rows() != 0)
		{
		    mysql_free_result();
			SendClientMessage(playerid, COLOR_SECURITY, "Please enter your password below to continue.");
	 		DisplayDialogForPlayer(playerid, 1);
	        return 0;
		}
		else
		{
		    mysql_free_result();
			SendClientMessage(playerid, COLOR_SECURITY, "Please enter a password below to register an account.");
	 		DisplayDialogForPlayer(playerid, 2);
	        return 0;
		}
	}
	return 1;
}
Код:
public OnPlayerConnect(playerid)
{
	PlayersOnline++;
	SessionStatus[playerid] = 1; //Connected. Do not show messages.
	if(GlobalStatus == 2)
	{
	    SendClientMessage(playerid, COLOR_SECURITY, "A MySQL error has occured. Please visit the forums for further details.");
	    Kick(playerid);
	}
	if(PlayersOnline > ServerMaxPlayers && sTrackPlayers == 1)
	{
	    new msg[256];
	    format(msg,sizeof(msg),"Life of Flying has reached a new top player count! (Previously %d online players at %s - %s)",ServerMaxPlayers,ServerMaxPlayersDate,ServerMaxPlayersTime);
	    SendClientMessageToAll(COLOR_VIP, msg);
	    ServerMaxPlayers = PlayersOnline;
		new date,month,year;
		getdate(date,month,year);
		new hour,minute,second;
		gettime(hour,minute,second);
		new string[128];
		format(string,sizeof(string),"%d/%d/%d",year,month,date);
		strmid(ServerMaxPlayersDate, string, 0, strlen(string), 128);
		format(string,sizeof(string),"%d:%d:%d",hour,minute,second);
		strmid(ServerMaxPlayersTime, string, 0, strlen(string), 128);
		SaveStuff();
	}
	CheckIPS(playerid);
	PurelySpawned[playerid] = 0;
	ResetMissionData(playerid);
	ResetPlayerData(playerid);
	CheckBanned(playerid);
	RemoveObjectsForPlayer(playerid);
	ResetPlayerData(playerid);
	UpdatePlayerColour(playerid);
	TextDrawShowForPlayer(playerid, Clockzz);
	MapSystemAddPlayer(playerid);
	PlayerPlaySound(playerid, 1187, 0, 0, 0); // Start the music
	if(PlayerLogged[playerid] == 0)
	{
 	mysql_reconnect();
		new	Query[90], EscName[MAX_PLAYER_NAME];
		mysql_real_escape_string(PlayerName(playerid), EscName);
		format(Query, sizeof(Query), "SELECT NULL FROM `users` WHERE `username` = '%s'", EscName);
		mysql_query(Query);
		mysql_store_result();
		if(mysql_num_rows() != 0)
		{
		    mysql_free_result();
			SendClientMessage(playerid, COLOR_SECURITY, "Please enter your password below to continue.");
	 		DisplayDialogForPlayer(playerid, 1);
	        return 0;
		}
		else
		{
		    PlayerPlaySound(playerid, 44204, 0, 0, 0);
		    mysql_free_result();
			SendClientMessage(playerid, COLOR_SECURITY, "Please enter a password below to register an account.");
	 		DisplayDialogForPlayer(playerid, 2);
	        return 0;
		}
 	}
	return 1;
}
Код:
if(dialogid == 1) //LOGIN
    {
		if(PlayerLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_YELLOW, "You are already logged in !");
			return 1;
		}
		if(response)
		{
		    if(!strlen(inputtext))
		    {
		        DisplayDialogForPlayer(playerid, 1); //login
				SendClientMessage(playerid, COLOR_YELLOW, "You must enter a password !");
				return 1;
			}
			if(strlen(inputtext) >= 50)
			{
			    DisplayDialogForPlayer(playerid, 1); //login
				SendClientMessage(playerid, COLOR_YELLOW, "That password is too long !");
				return 0;
			}
	        new tmppass[64];
	        //Store Player ID & TMP pass in echo to find string used to crash server
	        strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
	        PlayerLogin(playerid,tmppass);
		}
        else
        {
            SessionStatus[playerid] = 3;
            SendClientMessage(playerid, COLOR_SECURITY, "You have decided to quit. You have been kicked."); //login
            Kick(playerid);
        }
    }
    if(dialogid == 2) //REGISTER
    {
        if(PlayerLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_ERROR, "You are already logged in !");
			return 1;
		}
		if(response)
		{
		    if(strlen(inputtext) >= 50)
			{
			    DisplayDialogForPlayer(playerid, 2); //register
				SendClientMessage(playerid, COLOR_ERROR, "Password is too long !");
				return 0;
			}
		    new sendername[MAX_PLAYER_NAME];
			GetPlayerName(playerid, sendername, sizeof(sendername));
			{
			    if(!strlen(inputtext))
		    	{
			        DisplayDialogForPlayer(playerid, 2); //register
					SendClientMessage(playerid, COLOR_ERROR, "Please enter a password for your account !");
					return 1;
				}
   				mysql_reconnect();
				new Query[90], EscName[MAX_PLAYER_NAME];
				mysql_real_escape_string(PlayerName(playerid), EscName);
				format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s'", EscName);
				mysql_query(Query);
				mysql_store_result();
				if(mysql_num_rows() != 0)
				{
	    			mysql_free_result();
					SendClientMessage(playerid, COLOR_ERROR, "Name already registered. Please choose a different name !");
					return 1;
				}
				else
				{
					RegisterAccount(playerid,inputtext);
					JustRegistered[playerid] = 1;
					new tPlayers = 0;
					mysql_query("SELECT NULL from `users`");
					mysql_store_result();
					tPlayers = mysql_num_rows();
					mysql_free_result();
					new login[156];
					format(login, sizeof(login), "{1B8AE4}%s (%d) {FFFFFF}has created an account. (%d total accounts)", PlayerName(playerid), playerid, tPlayers);
					for(new i = 0; i <MAX_PLAYERS; i++)
					{
						if(IsPlayerConnected(i))
						{
						    if(PInfo[i][sConnectionMessages] == 0)
						    {
								SendClientMessage(i, COLOR_YELLOW, login);
							}
						}
					}
					SendClientMessage(playerid, COLOR_MESSAGE, "Your account has been successfully registered.");
					PlayerLogin(playerid,inputtext);
				    SetPlayerVirtualWorld(playerid, 0);
                	mysql_free_result();
				}
			}
		}
		else
		{
		    DisplayDialogForPlayer(playerid, 2); //register
		}
    }
Reply
#6

Quote:
Originally Posted by Ayyash
Посмотреть сообщение
But i Type The Same Password
You aren't understanding what I'm saying.

I haven't read the code you've just submitted but I want to explain something.

Say you have whirlpool to encrypt your passwords, when you register with a password test123, it takes that password and encrypts it with whirlpool.. So if you go into your database, if you still see test123 as the password, then it isn't encrypted, if you see a bunch of numbers and letters
Код:
[eg. 7d73388f9b889b1e59642aee80007658a8b3041bc6b5f52cfc5e88c84b04dff67a74e05eb31280ff609177bb27c6093df4d41ebfdf5be8112220f85ae84d0ce4]
That mean's it's encrypted.

Now when you go to login, if it's encrypted with whirlpool, when you type your password it, it has to verify with the password saved in the database, if it matches, it'll work. If inside your login code you don't verify it through whirlpool, it's basically going to go
Код:
does test123 = 7d73388f9b889b1e59642aee80007658a8b3041bc6b5f52cfc5e88c84b04dff67a74e05eb31280ff609177bb27c6093df4d41ebfdf5be8112220f85ae84d0ce4
(Which obviously it doesn't). It basically needs to hash your password and then compare it with the one in the database.

Does that make sense?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)