Jump to content

md5 + Trigger


n30x

Recommended Posts

Hi all.

I tryed to do a form that sends your account to forums database on 'serveraccount' field of 'users' table.

Here's the code located at the trigger that gets triggered when you click login and entered username + password:

addEvent("rru:requestloginsite", true) 
addEventHandler("rru:requestloginsite", root, 
    function(player, username, password) 
        password = mysql_query(forum_connect,"SELECT password FROM user WHERE username = '"..username) 
        encrypt.password = md5(password) 
        local useraccount = getAccountName(getPlayerAccount(player)) 
        outputChatBox(encrypt.password) 
        if (encrypt.password == password) then 
        -- SENDING YOUR ACCOUNT TO FORUMS 
        outputChatBox"sending" 
        --mysql_query(forum_connect,"ALTER TABLE users ADD serveraccount varchar(100)") 
        mysql_query(forum_connect,"UPDATE users SET serveraccount = "..useraccount.." WHERE username = '"..username.."'") 
        else 
        -- FAILED SENDING YOUR ACCOUNT TO FORUMS 
        outputChatBox"failed" 
        end 
    end 
) 

The problem is that it outputs "failed". Can somebody help me, please ?

Thanks.

Link to comment
Hi all.

I tryed to do a form that sends your account to forums database on 'serveraccount' field of 'users' table.

Here's the code located at the trigger that gets triggered when you click login and entered username + password:

addEvent("rru:requestloginsite", true) 
addEventHandler("rru:requestloginsite", root, 
    function(player, username, password) 
        password = mysql_query(forum_connect,"SELECT password FROM user WHERE username = '"..username) 
        encrypt.password = md5(password) 
        local useraccount = getAccountName(getPlayerAccount(player)) 
        outputChatBox(encrypt.password) 
        if (encrypt.password == password) then 
        -- SENDING YOUR ACCOUNT TO FORUMS 
        outputChatBox"sending" 
        --mysql_query(forum_connect,"ALTER TABLE users ADD serveraccount varchar(100)") 
        mysql_query(forum_connect,"UPDATE users SET serveraccount = "..useraccount.." WHERE username = '"..username.."'") 
        else 
        -- FAILED SENDING YOUR ACCOUNT TO FORUMS 
        outputChatBox"failed" 
        end 
    end 
) 

The problem is that it outputs "failed". Can somebody help me, please ?

Thanks.

The problem with your code is that you you have 2 variable with the same name. 1st is coming from arguments and the other one is from database. Just change one variable name and you should be fine.

If you look closely, you change the value of password (the function argument) with the new password from database (which is already a hash of md5), then you hash its value with md5 (which will give you completely new value), then you compare these 2 different values. This is why it "fails".

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