Get and Post

Get and Post variables let you send variables between you pages. E.g. when submitting a form, or paging through through the results of search on website.

GET

Get variables are usually passed via a url (they can also be passed through a form when the method is set to get).

e.g. If a url was accessing the page search.lc with the url: search.lc?search=livecode, you can access the search variable like so:

<?lc
put $_GET["search"] // outputs: livecode
?>

POST

Post variables are typically passed when data is submitted via a form.
Post variables can be accessed in the exact same way as get variables, just using $POST instead.

<?lc
put $_POST["search"]
?>

Encoding GET parameters

When you are submitting data via a url, the data should be url encoded:

<?lc 
put urlEncode("For mice and men") // outputs: For+mice+and+men
?>

Leave a Reply