Jump to content
  • 0

function LOGIN


g1doz

Question

anyone help me to explain how to this script exchange data with server ?

function LOGIN()    
Variable = {}
Variable.LoginURL = "https://test.000webhostapp.com/ASQ/FE/Login.php"
local configFile = gg.EXT_CACHE_DIR .. "/" .. gg.getFile():match("[^/]+$") .. ".cfg"
local data = loadfile(configFile)

if data ~= nil then
data = data()
end    
local Prompt = gg.prompt({[[LOGIN HERE
Username]],
"Password","Remember Me"}, data, {"text", "text","checkbox"})

if Prompt == nil then
START()
end    

gg.saveVariable(Prompt, configFile)    

if Prompt[3] == false then 
os.remove(gg.EXT_CACHE_DIR .. "/" .. gg.getFile():match("[^/]+$") .. ".cfg")    
end    

Variable.TempLogin = '{"Username":"' .. Prompt[1] .. '","Password":"' .. Prompt[2] .. '"}'
ResponseContent = gg.makeRequest(Variable.LoginURL, nil, Variable.TempLogin).content

if not ResponseContent then
gg.alert('🔴 CHECK YOUR CONNECTION 🔴')
print("⚠ Something Went Wrong ⚠")
os.exit()
else
pcall(load(ResponseContent))
end    
end    

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Learn php.

Variable.TempLogin = '{"Username":"' .. Prompt[1] .. '","Password":"' .. Prompt[2] .. '"}'

This is json encoded string.

Example

Username : 123456
Password : Abc123456

With this input, you will get a json string like this:

{"Username":"123456","Password":"Abc123456"}

When this has post to your php, your php actually get the json string. Then now you can use json_decode to get the password.

$username = json_decode("Username",true);// Store the username of user into the variable "username"
$password = json_decode("Password",true);// Store the password of user into variable "password"

Then the data sent by Lua can be receive by PHP.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.