Implementing POST command to cgi

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Implementing POST command to cgi

Post by waprothero » Thu Oct 11, 2012 1:04 am

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.
Bill Prothero

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Implementing POST command to cgi

Post by shaosean » Thu Oct 11, 2012 7:05 am

open the docs, type in "post" in the search field in the top right, click the entry.. or http://docs.runrev.com/Command/post

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Implementing POST command to cgi

Post by Simon » Thu Oct 11, 2012 1:07 pm

Look up libUrlMultipartFormData.
The sample in there is exactly how I do it.

Ah "...to a database..." maybe not.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: Implementing POST command to cgi

Post by gpb01 » Thu Oct 11, 2012 1:39 pm

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

waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Re: Implementing POST command to cgi

Post by waprothero » Thu Oct 11, 2012 11:15 pm

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.
Bill Prothero

Post Reply