Post your best Lua script examples here

User avatar
By gerardwr
#4315
vincent1971 wrote:Is it possible to send the data from an input box in html to the lua server?


I'm working on a similar case. I guess the only way is to use the form action to sent the data to a URL.

I've got a form like this:
Code: Select all<form action="wifi.pht">
  SSID : <input type="text" name="APSSID" value="your ssid">
  PW   : <input type="text" name="APPASS" value="your password">
  <input type="submit" value="Set new SSID/PW">
</form>


When the button is clicked the browser is pointed to URL:
Code: Select allhttp://192.168.0.27/wifi.pht?APSSID=your+ssid&APPASS=your+password

On this page you need:
1. access to the full URL ( like $_GET in PHP)
2. some Lua code to to retrieve the parameter from the URL
3. some code to use the parameter for your own purpose.

For 1. I see no other option than change the webservercode. I declared a global variable (_GET) and copy the full URL request to it. Then it will be available for some embedded Lua script in the .PHT file of the page.

Am open for a more simple approach, anybody :?:

Let us know when you have any progress.
User avatar
By Erni
#4361 I am beginning to be (more) confused.
With the version of the webserver I have there is no problem with using a form and the get method.
If i use a form like this:

Code: Select all<form method="GET"><br><input type="text" name="data" value=Peter>
Number<input type="text" name="number" value=17><input type="submit" value="Get"></form>

I get the variable in the reqdata table

Code: Select all<?lua for k,v in pairs(reqdata) do print (k,v) end ?>


Now if you look at the link from 4 dec by adamip, you will see a different implementation with post and log.file, so I think we are working with different versions ?

Screenshot
Attachments
index.jpg
User avatar
By alonewolfx2
#4364 can you share your version?


Erni wrote:I am beginning to be (more) confused.
With the version of the webserver I have there is no problem with using a form and the get method.
If i use a form like this:

Code: Select all<form method="GET"><br><input type="text" name="data" value=Peter>
Number<input type="text" name="number" value=17><input type="submit" value="Get"></form>

I get the variable in the reqdata table

Code: Select all<?lua for k,v in pairs(reqdata) do print (k,v) end ?>


Now if you look at the link from 4 dec by adamip, you will see a different implementation with post and log.file, so I think we are working with different versions ?

Screenshot