You need to get the data to post, and then post that data to the url. Sounds glib I know, I'm not trying to patronise. Forget treating it like the form on the web page, all that does is put a GUI in the browser and submits the data to the processing page as defined by the form. So you can look at the source code for the form on the webpage and see what "action" and "method" are defined, and check the fields it is submitting to the form.
You might, for instance have a form with action "http://www.mydomain.com/formprocessor.php
" or, more likely a relative path to the current page, such as "formprocessor.php". So you know you would have to post your data to "http://www.mydomain.com/formprocessor.php
The data to be posted will be in the form of name=value pairs. You might find the form fields "username", "rating", "comment" (or anything at all that the form is supposed to be processing). In your livecode app you would need to be collecting whatever values your web target requires. You would then create a string of data to post and use that to submit to the url. The libURLFormData function will do this for you. You will also need to consider encoding any special characters (even spaces) in the string. So something like:
Code: Select all
put urlEncode(field "username") into tUsername
put urlEncode(field "rating") into tRating
put urlEncode(field "comment") into tComment
put libURLFormData("username", tUsername, "rating", tRating, "comment", tComment) into tDataToBePosted
post tDataToBePosted to url (field "urlOfWebForm")
put it into field "displayResult"
You need not put every individual field into a variable of its own before assembling, but it makes the actual libURLFormData function easier to read above.
If you need to preserve a session (for instance, if the form is asking for username and id to be able to log in) then you will also have to check headers received with the libURLLastRHHeaders() and parse out any cookies set, and set the httpHeaders
with the cookie value so that the server continues to accept the future connections as having authenticated.