Jump to content

[HELP] Login Panel Problem


Wunder

Recommended Posts

Greetings People!

I have a little problem with my Login Panel, because if i click on the Register button then nothing happens. I just tested my MySQL connection too ,  but its shows that the Connection is good and nothing comes out in the Debugscript either.

If anyone can help me with this then Thank you!

 

--Here is the Code for the Register function Server Side

function registerReq(player, username, password, email)
	local password = md5(password)
	local regQuery = dbPoll(dbQuery(connection, "SELECT * FROM accounts"),-1)
	if regQuery then
		for _, rows in ipairs(regQuery) do
			if rows["username"] == username then
				exports.vmInfoBox:addNotification(player,"Ezzel a felhasználóval már regisztráltak!", "error")
				return
			end
			if rows["serial"] == getPlayerSerial(source) then
				exports.vmInfoBox:addNotification(player,"Az adott Serial már regisztrálva van!", "error")
				return
			end
			insertinfo = dbExec(connection, "INSERT INTO accounts SET username = ?, password = ?, ip = ?, serial = ?, email = ?, banned='0', online='0', regdate=NOW()", username, password, getPlayerIP(source), getPlayerSerial(source), email, banned, online, regdate)
			if insertinfo then
				exports.vmInfoBox:addNotification(player,"Sikeres regisztráció!", "success")
			else
				exports.vmInfoBox:addNotification(player,"Valami hiba történt, keress fel egy fejlesztöt!", "error")
			end
		end
	end
end
addEvent("registerReq", true)
addEventHandler("registerReq", getRootElement(), registerReq)
-- This is the code for Client Side

function regregisterClick(button, state)
	if button == "left" and state == "down" then
		if source == regregbutton then
			if string.len(DGS:dgsGetText(reguseredit)) < 5 then
				exports.vmInfoBox:addNotification("A felhasználónév minimum 5 karakterböl kell állnia!", "error")
				return
			end
			if string.len(DGS:dgsGetText(regpasswedit)) < 6 then
				exports.vmInfoBox:addNotification("A jelszó minimum 6 karakterböl kell állnia!", "error")
				return
			end
			if DGS:dgsGetText(regpasswedit) ~= DGS:dgsGetText(regpasswedit2) then
				exports.vmInfoBox:addNotification("A két megadott jelszó nem egyezik!", "error")
				return
			end
			if string.len(DGS:dgsGetText(regmailedit)) < 7 then
				exports.vmInfoBox:addNotification("Az email cím minimum 7 karakterböl kell állnia!", "error")
				return
			end
			if not string.find(DGS:dgsGetText(regmailedit), "@") and string.find(DGS:dgsGetText(regmailedit), ".") then
				exports.vmInfoBox:addNotification("Kérlek adj meg egy érvényes email címet!", "error")
				return
			end
			if DGS:dgsGetText(reguseredit) == "" and DGS:dgsGetText(regpasswedit) == "" and DGS:dgsGetText(regpasswedit2) == "" and DGS:dgsGetText(regmailedit) == "" then
				exports.vmInfoBox:addNotification("Ne hagyd üresen a mezöket!", "error")
			end
				triggerServerEvent("registerReq", localPlayer, localPlayer, DGS:dgsGetText(reguseredit),DGS:dgsGetText(regpasswedit),DGS:dgsGetText(regpasswedit2),DGS:dgsGetText(regmailedit))
		end
	end
end
addEventHandler("onDgsMouseClick", getRootElement(), regregisterClick)

 

Link to comment

You are attempting to poll a query result that may not be ready yet, the way you have declared your regQuery is not asynchronous.

When you execute the query the result isn't immediately ready, so you should wait for a result to be prepared and then execute a callback function.

function myFunction()
    dbQuery(myCallback, connection, "SELECT * FROM table_name")
end

function myCallback(qh)
    local result = dbPoll(qh, -1)
	-- Do stuff with result here.
end


See dbQuery for examples.

Also I noticed you're storing passwords with md5, I wouldn't recommend doing so because md5 can be easily cracked, you should use a more secure method such as passwordHash.

Edited by Skully
Link to comment
25 minutes ago, Skully said:

You are attempting to poll a query result that may not be ready yet, the way you have declared your regQuery is not asynchronous.

When you execute the query the result isn't immediately ready, so you should wait for a result to be prepared and then execute a callback function.


function myFunction()
    dbQuery(myCallback, connection, "SELECT * FROM table_name")
end

function myCallback(qh)
    local result = dbPoll(qh, -1)
	-- Do stuff with result here.
end


See dbQuery for examples.

Also I noticed you're storing passwords with md5, I wouldn't recommend doing so because md5 can be easily cracked, you should use a more secure method such as passwordHash.

Thank You, i appreciate your answer and also thanks for the tips!

 

Link to comment
1 hour ago, Wunder said:

I tried every possible solution but still its not working.

Alright, it was my mistake... because the dbExec was still inside the for loop and thats why it was not working properly. Thanks anyway! :)

 

If a moderator is here then please your can close this thread.

Edited by Wunder
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...