post command example?
Martin Baxter
martin at materiaprima.fsnet.co.uk
Wed Jun 29 02:59:05 EDT 2005
Devin Asay wrote:
> I need to send some data to a php page on a web server, just a short
> string like "abc2". I've read all I can find on the post command in the
> documentation, but can't figure out how to format the data so the php
> script will read it.
>
> My stack:
> contents of fld "uid": "abc2"
> (I also tried [ name="netid" value="dna3" ] as the value of the field.
> Sans the [].)
>
> the post button script:
> on mouseUp
> post urlencode(fld "uid") to url fld "urlText" -- also tried without
> urlencode
> set the htmltext of fld "returnedText" to it
> end mouseUp
>
> The result returned makes it obvious that the php script executed, but
> never received the value "abc2".
>
> FWIW, the php script (one I wrote, that works when I hard code
> everything) uses the $POST_[value name here] format to grab the data. I
> am a neophyte in php land, but have used this method successfully in
> the past to pass values from html forms.
>
> There are no clear examples of how to do this in the docs, and the list
> archive at http://lists.runrev.com seems to be offline at the moment.
> Can anyone point me in the right direction?
>
> Devin
Hi Devin,
Maybe the problem is that you need to use ampersand to delimit the name
value pairs rather than space.
Here is how I format the data
put "any old text." into msgtext
put urlencode(msgtext) into msgtext
put "username" into tuser
put "username=" & tuser & "&message=" & msgtext into data
## note no spaces and the use of ampersand to delimit the
## name value pairs
## tuser is known not to require urlencoding
put "http://domain/path/document.php" into phpurl
post data to url phpurl
HTH
Martin Baxter
More information about the use-livecode
mailing list