Good evening, everyone.
Perhaps someone can help with the solution to this problem.
function demo_generator()
local num1 = math.random(1, 10)
local num2 = math.random(1, 10)
local answer = num1 + num2
return answer
end
local VariableB = demo_generator()
local test_html = [[
<!DOCTYPE html>
<html>
<body>
]] .. VariableB .. [[
<form action="" method="post">
<label for="digs">Code:</label><br>
<input type="text" id="digs" name="digs" value=""><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
]]
if ngx.req.get_method() == "POST" then
ngx.req.read_body()
local post_args = ngx.req.get_post_args()["digs"]
ngx.say("user send : ", post_args)
ngx.say("original value:", VariableB)
return
end
ngx.say(test_html)
In this example, the code of the function , is called twice.
As a result, it is not possible to check what the user has entered with what we have received.
Perhaps someone can suggest a solution to this problem ?