problem with database SQLite
#1

Heyy, I have a problem with my database (SQLite). When I register an account, everything works fine, the system saves the name and its respective password, but, when I log back in, it asks me to enter my account password, right? Well, when I enter the password, it tells me that it is WRONG (and I have entered the correct password), and it is a problem that I have still been able to solve (the game mode is made from 0 for my, forgive my ignorance, I am learning).

Code:
HTML Code:
		case D_LOGIN:
		{
			if(!response) return Kick(playerid);
			{
				new DBResult:resultado, l_sQuery[350];
				format(l_sQuery, sizeof(l_sQuery), "SELECT * FROM `USUARIOS` WHERE Nick = '%q' COLLATE NOCASE AND Password = '%q'", GetPlayerNameEx(playerid), PI[playerid][e_sPassword]);
				resultado = db_query(edb, l_sQuery);
				if(db_num_rows(resultado))
				{
					new l_sString[70];
					
					CargarCuenta(playerid);

					PI[playerid][e_bSesion] = true;

					PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);

					format(l_sString, sizeof(l_sString), "Welcome!, %s", GetPlayerNameEx(playerid));
					Mensaje(playerid, -1, l_sString);
				}
				else
				{
					ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Log In", "{FFBF00}* {FF6262}ERROR: {FFFFFF}The entered password is incorrect.\n{FFBF00}* {FFFFFF}Please re-enter the account password to log in.", "Join", "Leave");
				}
				db_free_result(resultado);
			}
		}
Reply
#2

In this particular line of code

Code:
format(l_sQuery, sizeof(l_sQuery), "SELECT * FROM `USUARIOS` WHERE Nick = '%q' COLLATE NOCASE AND Password = '%q'", GetPlayerNameEx(playerid), PI[playerid][e_sPassword]);
You seem to be using an already loaded password here. You need to get the password value from the "inputtext" variable which contains the value of the responded dialog. Which would go like this.

Code:
format(l_sQuery, sizeof(l_sQuery), "SELECT * FROM `USUARIOS` WHERE Nick = '%q' COLLATE NOCASE AND Password = '%q'", GetPlayerNameEx(playerid), inputtext);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)