Page 1 of 1
Implementing POST command to cgi
Posted: Thu Oct 11, 2012 1:04 am
by waprothero
I want to send parameters to a cgi using a POST command. How do I do this? I need to have the ability to send moderately large chunks of text to a database. The tutorials are pretty clear on acquiring data from a database, but creating http requests using GET is not going to allow me to send enough text unless I get complex with breaking it up into smaller chunks. POST would be much simpler.
I see a number of postings that refer to POST "xxxxx" to URL, etc, etc. Where is the POST command documented. I'm interested in using it in livecode scripts.
Re: Implementing POST command to cgi
Posted: Thu Oct 11, 2012 7:05 am
by shaosean
open the docs, type in "post" in the search field in the top right, click the entry.. or
http://docs.runrev.com/Command/post
Re: Implementing POST command to cgi
Posted: Thu Oct 11, 2012 1:07 pm
by Simon
Look up libUrlMultipartFormData.
The sample in there is exactly how I do it.
Ah "...to a database..." maybe not.
Simon
Re: Implementing POST command to cgi
Posted: Thu Oct 11, 2012 1:39 pm
by gpb01
waprothero wrote:.... Where is the POST command documented. I'm interested in using it in livecode scripts.
In my DropBox library, freely available
HERE, you can see the POST statement in use for a Content-Type: "multipart/form-data" (
see the phx_DropboxWriteFile function) ...
... maybe can help
Guglielmo
Re: Implementing POST command to cgi
Posted: Thu Oct 11, 2012 11:15 pm
by waprothero
Actually, this turns out to be pretty easy. Do you see any problems with this?
on mouseUp
put "name" into key_1
put "BillyBoy" into value_1
put "name2" into key_2
put "John Person" into value_2
get libUrlFormData(key_1,value_1,key_2,value_2)
post it to url "
http://myURL/lcp/testPost.php"
answer it
end mouseUp
-----------------------------------------
the php script is, for the test:
<?php
echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!' . "\n";
echo 'Hello again: ' . htmlspecialchars($_POST["name2"]) . '!' . "\n";
echo 'Got to test';
?>
Now all I've got to do is use my php to access the database and echo back the resuilts in nice xml.
I'll need a progress bar, of course.