Syntrax# Posted January 20, 2016 Share Posted January 20, 2016 Fellow community, I've recently finished the design of my new login panel,but now i ame to the server side i've encoutered a problem.I've been using Raysmta solution to connect ot IPB but now it doesn't work at all,i only get the outputdebugscript [ [ ] ] It doesn't give any other information -- Serverside function PlayerLogin(username,password) callRemote("http://dynastynetworkrpg.net/userconnection.php", function(...) outputDebugString(toJSON({...})) end, "verifyPasswords", username, password) if response == true then outputDebugString("Right Pass.") triggerClientEvent (source,"onLoginSuccess",getRootElement()) -- password correct else if extra == 1 then outputDebugString("Wrong Pass.") -- password incorrect elseif extra == 2 then -- account not found outputDebugString("Acc not found") end end end addEvent("onRequestLogin",true) addEventHandler("onRequestLogin",getRootElement(),PlayerLogin) function registerPlayer(rusername,rpassword,rlocalplayername,rmail,rconfirmpass) if not (rusername == "") then if not (rpassword == "") then if not (rmail == "") then local account = getAccount (rusername) if (account == false) then local accountAdded = addAccount(tostring(rusername),tostring(rpassword)) executeSQLInsert("database_accountGroups","'"..rusername.."','[ [ ] ]'") setAccountData(accountAdded, "money", 0) if (accountAdded) then dbExec( connection,"INSERT INTO Userdata (AccountName,LastName,Money,Kills,Deaths,Arrests,Lastlogin,Email,Hours,OwnedCars) VALUES(?,?,?,?,?,?,?,?,?,?)", rusername, rlocalplayername, 0, 0, 0, 0, "SOON", rmail, 0, "None" ) triggerClientEvent(source,"onRegisterSuccess",getRootElement(),sRegistererror, srr, srg, srb) triggerClientEvent(source,"onRegisterSuccess1",getRootElement()) else sRegistererror = "Unknown error,contact an available admin" srr, srg, srb = 255, 128, 0 triggerClientEvent(source,"onRegisterFail",getRootElement(),sRegistererror, srr, srg, srb) end else sRegistererror = "Account already exist in our database" srr, srg, srb = 255, 128, 0 triggerClientEvent(source,"onRegisterFail",getRootElement(),sRegistererror, srr, srg, srb) end else sRegistererror = "No email has been entered" srr, srg, srb = 170, 0, 0 triggerClientEvent(source,"onRegisterFail",getRootElement(),sRegistererror, srr, srg, srb) end else sRegistererror = "No password has been entered" srr, srg, srb = 170, 0, 0 triggerClientEvent(source,"onRegisterFail",getRootElement(),sRegistererror, srr, srg, srb) end else sRegistererror = "No Username has been entered" srr, srg, srb = 170, 0, 0 triggerClientEvent(source,"onRegisterFail",getRootElement(),sRegistererror, srr, srg, srb) end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) -- PHP <?php // PHP include 'mta_sdk.php'; // Correct path if you use a different one $servername = "localhost"; // Change these details $username = "root"; // Change these details $password = "*********"; // Change these details $dbname = "dynasty"; // Change these details $table = "core_members"; $accountColumn = "name"; // change to "email" if you prefer logging in through email $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { mta::doReturn(false, "Connection failed: " . mysqli_connect_error()); // Account not found #die("Connection failed: " . mysqli_connect_error()); } $input = mta::getInput(); if (isset($input[0]) && isset($input[1]) && isset($input[2]) && $input[0] == "verifyPasswords" ) { $sql = "SELECT `members_pass_salt`, `members_pass_hash` FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[1])."' LIMIT 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); if (crypt($input[2], '$2a$13$' . $row['members_pass_salt']) == $row['members_pass_hash']) { mta::doReturn(true, 0); // Password correct } else { mta::doReturn(false, 1); // Passwords don't match } } else { mta::doReturn(false, 2); // Account not found } } // Author: MrTasty ?> Link to comment
tosfera Posted January 21, 2016 Share Posted January 21, 2016 Visit the PHP script in your browser and see if it's throwing any errors, try to add some debug lines and see what's wrong. I think that when the PHP returns an error, MTA will receive an empty object. Or the script is just sending an empty object since error_reporting is most likely turned off in IPB. Link to comment
Syntrax# Posted January 21, 2016 Author Share Posted January 21, 2016 Visit the PHP script in your browser and see if it's throwing any errors, try to add some debug lines and see what's wrong. I think that when the PHP returns an error, MTA will receive an empty object. Or the script is just sending an empty object since error_reporting is most likely turned off in IPB. Doesn't Give any errors when i'm visiting the link,let me see if i can find a way to get the error code Link to comment
Syntrax# Posted January 21, 2016 Author Share Posted January 21, 2016 tried everything i could but nothing can't get it to work somehow,can anyone help me out with this ? Link to comment
tosfera Posted January 21, 2016 Share Posted January 21, 2016 Try to simply remove line by line in the php script until you get something as a return. You're simply getting an empty json_encode in your lua script so it has to be in your php script. Maybe the thing you send towards the script or something that has been messed up in there. 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