Jump to content

Login Panel MYSQL problem


Firespider

Recommended Posts

Hello, I would like to make the system check that the player has entered a good password. But for some reason this line of code is not good.

server side: 

addEvent("attemptLogin", true)
addEventHandler("attemptLogin", resourceRoot, function(username, pass)
    local serial = getPlayerSerial(client)
    dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial)
    result = dbPoll(dq, 500)
    if (#result > 0) then
        if (result[1]["username"] == username) then
            if (result[2]["password"] == pass) then
                outputChatBox("Sikerült")
            else
                outputChatBox("Nem Sikerült")
            end
        end
    end
end)


client side:

function Login()
if Data[1][1] ~= "" or Data[1][2] ~= "" then
        triggerServerEvent("attemptLogin", resourceRoot, Data[1][1], hash("sha512", Data[1][2]))
	else
		LogAlert("EmptyRectangle")
    end
end	


Error code:

spacer.png

Link to comment
  • Moderators
1 hour ago, Firespider said:

But for some reason this line of code is not good.

 

You might want to check if there is actually is data and what the data structure is.

iprint("Validating variable Data:", inspect(Data)) -- debug in /debugscript 3

if not Data then return LogAlert("EmptyRectangle") end -- something is really wrong

local loginCredentials = Data[1]
if not loginCredentials then return LogAlert("EmptyRectangle") end -- no loginCredentials

local username = loginCredentials[1] 
local pass = loginCredentials[2] 
if (username ~= "" or pass ~= "") then return LogAlert("EmptyRectangle") end -- no user name of password

triggerServerEvent("attemptLogin", resourceRoot, username, hash("sha512", pass))

 

 

Link to comment
26 minutes ago, Firespider said:
Thanks, but I've already created the data, so the problem won't be there. At least I think so
 
 
 
 

Also do you have data in db? Also u can try to loop through result and see if something comes from db. Also when u send the data from client to server check on server side if something comes

outputDebugString(username)
outputDebugString(password)

 

Link to comment
  • Moderators
On 08/08/2023 at 18:27, Firespider said:

Thanks, but I've already created the data, so the problem won't be there. At least I think so

In that case it might be handy if we know at which line + file the error is occurring.

Link to comment
  • Moderators
9 hours ago, Firespider said:
if result[2]["password"] == pass then

if result[2]["password"] == pass then

And if you do:

if result[1]["password"] == pass then

Since normally you want to get the username and password from the same row.

 

Link to comment
  • Moderators
42 minutes ago, Firespider said:

but the system indicates that the password is not correct and I enter it correctly

In that case you might want to view those in the debug console and check how they differ.

iprint(result[1]["password"], pass)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...