Jump to content

MySql Login Problem


Recommended Posts

Hey Guys,I've Been Making a Login Panel with mysql

i made a register command first to see if it's working,it worked good with "INSERT"

but when i tried to login it doesn't want to login,so can anyone help me please?it doesn't give me any errors

here the serverside code

function LoginPlayer(playerSource, commandName, _password) 
  handler = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1","root","") 
  local name = getPlayerName(playerSource) -- Escape the strings to avoid SQL-Injection 
  local password =  _password 
  local query = " SELECT * FROM smf_players WHERE username='" .. name .. "' AND password='" .. md5(password) .. "'" 
  
  if (dbQuery(handler, query)) then 
    local rows = dbPoll(dbQuery(handler, query),-1) 
        if rows == 1 then 
            outputChatBox("You Succefully Logged In.", playerSource) 
        else 
        outputChatBox("An error has occured when trying to login", playerSource) 
    end 
  end 
end 
addCommandHandler("loginn", LoginPlayer) 

Link to comment

you mean like that?

handler = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1","root","")     
function LoginPlayer(playerSource, commandName, _password) 
      local name = getPlayerName(playerSource) -- Escape the strings to avoid SQL-Injection 
      local password =  _password 
      local query = " SELECT * FROM smf_players WHERE username='" .. name .. "' AND password='" .. md5(password) .. "'" 
      
      if (dbQuery(handler, query)) then 
        local rows = dbPoll(dbQuery(handler, query),-1) 
            if rows == 1 then 
                outputChatBox("You Succefully Logged In.", playerSource) 
            else 
            outputChatBox("An error has occured when trying to login", playerSource) 
        end 
      end 
    end 
    addCommandHandler("loginn", LoginPlayer) 

Link to comment
handler = dbConnect ( "mysql", "dbname=DBNAME;host=127.0.0.1", "root", "" ) 
  
function LoginPlayer ( playerSource, commandName, _password ) 
    local name = getPlayerName ( playerSource ) -- Escape the strings to avoid SQL-Injection 
    local query = dbQuery ( handler, "SELECT * FROM smf_players WHERE username = ? AND password = ?", name, md5 ( _password ) ) 
    if ( query ) then 
        local result, rows = dbPoll ( query, -1 ) 
        if ( rows == 1 ) then 
            outputChatBox ( "You Succefully Logged In.", playerSource ) 
        else 
            outputChatBox ( "An error has occured when trying to login", playerSource ) 
        end 
    end 
end 
addCommandHandler ( "loginn", LoginPlayer ) 

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...