How do I pass information to LiveCode Server scripts?
The LiveCode Server product brings our english like language to the server environment. The server engine is a separate build of the LiveCode engine with specific syntax and functionality that makes it suitable for use in command-line contexts and, in particular, as a CGI processor.
This lesson will walk you through the steps required to pass data to your LiveCode Server scripts.
One means to pass data to your LiveCode Server scripts is to include the required information in the URL. Consider a script residing at the following location:
We can pass data to this script by appending a question mark and then <key>=<value> pairs. For example, if we wanted to pass the value "RunRev" in the key "company" we would do the following:
Data passed in the URL will be accessible to your LiveCode scripts via the global array variable $_GET. The following example demonstrates how to access the "company" information as passed int he previous script:
put "Your company name is" && $_GET["company"]
Any data included in the URL must be url encoded. This ensures that the data is properly escaped and ready for transfer. You can do this using the LiveCode function "urlEncode":
get urlEncode("Lord of the Rings")
This will result in a URL looking like the following:
Additional parameters can be included in the URL by separating with ampersands. Say, for example, you wanted to include a type and category to our URL, you would do the following:
For more information on passing and handling data, see the lesson "How do I handle user input using LiveCode Server?"