Jimmy. Posted July 14, 2015 Share Posted July 14, 2015 I check or row is exist, but always got " Wrong username" even username is in database. Where can be a mistake? function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) local result = dbPoll( query, -1 ) if result == true then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if result then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 dbPoll doesn't return boolean value. function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) local result = dbPoll( query, -1 ) if result then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if result then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Link to comment
Jimmy. Posted July 14, 2015 Author Share Posted July 14, 2015 dbPoll doesn't return boolean value. function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) local result = dbPoll( query, -1 ) if result then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if result then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) But now always show: "Welcome to My Server." Or wrong username or no. Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 Oh, use this: function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) local result = dbPoll( query, -1 ) if #result == 1 then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if #result == 1 then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Link to comment
Jimmy. Posted July 14, 2015 Author Share Posted July 14, 2015 Again always "Wrong username". Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 Then you're entering wrong username. Debug the code like: function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) local result = dbPoll( query, -1 ) outputChatBox(#result) if #result == 1 then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if #result == 1 then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Also, don't forget to use dbFree. Link to comment
Jimmy. Posted July 14, 2015 Author Share Posted July 14, 2015 outputChatBox shows "0" Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 It's wrong username. What username did you enter exactly? Link to comment
Jimmy. Posted July 14, 2015 Author Share Posted July 14, 2015 It's wrong username. What username did you enter exactly? The same "0". Maybe something can be wrong with clientside? Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 Maybe. Output username and then compare to the row in the table. function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) outputChatBox(username) local result = dbPoll( query, -1 ) outputChatBox(#result) if #result == 1 then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if #result == 1 then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Link to comment
Jimmy. Posted July 14, 2015 Author Share Posted July 14, 2015 Maybe. Output username and then compare to the row in the table. function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=?", username) outputChatBox(username) local result = dbPoll( query, -1 ) outputChatBox(#result) if #result == 1 then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=? AND password=?",username,password) local result = dbPoll( query, -1 ) if #result == 1 then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) outputChatBox(username) here it is okay, what i wrote, output show the same. I send PM my all clientside file. Link to comment
GTX Posted July 14, 2015 Share Posted July 14, 2015 There is no problem in client-sided file. Try: function loginHandler(username,password) local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=`??`", username) local result = dbPoll( query, -1 ) outputChatBox(#result) if #result == 1 then local query = dbQuery(handler,"SELECT * FROM accounts WHERE username=`??` AND password=`??`",username,password) local result = dbPoll( query, -1 ) if #result == 1 then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputDebugString("Welcome to My Server.") end else outputDebugString("Wrong password.") end else outputDebugString("Wrong username.") end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",root,loginHandler) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now