n30x Posted April 9, 2012 Share Posted April 9, 2012 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
Wei Posted April 9, 2012 Share Posted April 9, 2012 bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] ) Link to comment
n30x Posted April 9, 2012 Author Share Posted April 9, 2012 I need help with md5 not outputchatbox. PD: outputChatBox is working. Link to comment
Castillo Posted April 9, 2012 Share Posted April 9, 2012 I'm guessing "encrypt" is a table, right? maybe you're messing Lua with another coding language. Link to comment
50p Posted April 9, 2012 Share Posted April 9, 2012 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
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