post url newbie
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
post url newbie
I'm trying to convert the code below to Rev:
~~~~~~~~~~~
OleObject ie
integer li_rc
string s, msg, q
q = "select * from status"
ie = CREATE OleObject
li_rc = ie.ConnectToNewObject( "Microsoft.XMLHTTP" )
ie.open( "POST", "http://test/query_test.php", False )
ie.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded")
s = URLEncode( q )
TRY
ie.send( "query=" + s)
CATCH (RuntimeError ErrPrint)
MessageBox("ERROR",ErrPrint.GetMessage() )
END TRY
If ie.readyState <> 4 then
msg = "Failed"
else
msg = string(ie.responseText)
end if
MessageBox("HTTP Response", msg)
destroy ie
~~~~~~
but the example in the dictionary is incomplete:
post myData to URL "http://www.example.net/indications.cgi"
post field "Return Values" to URL field "Current Page"
I need to pass the query string to php page "query=" + s. Please help.
~~~~~~~~~~~
OleObject ie
integer li_rc
string s, msg, q
q = "select * from status"
ie = CREATE OleObject
li_rc = ie.ConnectToNewObject( "Microsoft.XMLHTTP" )
ie.open( "POST", "http://test/query_test.php", False )
ie.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded")
s = URLEncode( q )
TRY
ie.send( "query=" + s)
CATCH (RuntimeError ErrPrint)
MessageBox("ERROR",ErrPrint.GetMessage() )
END TRY
If ie.readyState <> 4 then
msg = "Failed"
else
msg = string(ie.responseText)
end if
MessageBox("HTTP Response", msg)
destroy ie
~~~~~~
but the example in the dictionary is incomplete:
post myData to URL "http://www.example.net/indications.cgi"
post field "Return Values" to URL field "Current Page"
I need to pass the query string to php page "query=" + s. Please help.
Re: post url newbie
It's not incomplete. your query goes into the "myData" part of the first example.
for example
for example
Code: Select all
put "blahblah" into myQuery
urlencode(myQuery)
post myQUery to url "http://someurlthatimadeup.justnow"
put the result && it
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: post url newbie
I'm trying to do this:
put "id_no=100" into myQuery
urlencode(myQuery)
post myQUery to url "http://localhost"
put the result && it
I already have web server set up (xampp) with a php service handler. My php handler looks like this:
if ( isset($_REQUEST['id_no']) ) {
print "ok<b>" ;
}
else
{
print "NOT ok<b>" ;
}
But I keep getting NOT ok. So how do set the POST variable "id_no"?
put "id_no=100" into myQuery
urlencode(myQuery)
post myQUery to url "http://localhost"
put the result && it
I already have web server set up (xampp) with a php service handler. My php handler looks like this:
if ( isset($_REQUEST['id_no']) ) {
print "ok<b>" ;
}
else
{
print "NOT ok<b>" ;
}
But I keep getting NOT ok. So how do set the POST variable "id_no"?
Re: post url newbie
Hi gwbasic,
Don't urlEncode "id_no=100" in its entirety. Instead, just urlEncode "100".
put "id_no=" & urlEncode("100") into myQuery
This will leave "100" unaffected, but when you are going to use more complex strings, encoding the data will appear useful. Don't encode the variable names and the "=" signs. Encode the data only.
Best,
Mark
Don't urlEncode "id_no=100" in its entirety. Instead, just urlEncode "100".
put "id_no=" & urlEncode("100") into myQuery
This will leave "100" unaffected, but when you are going to use more complex strings, encoding the data will appear useful. Don't encode the variable names and the "=" signs. Encode the data only.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: post url newbie
gwbasic,
Have you read the documentation about the https keyword and tried it?
Best,
Mark
Have you read the documentation about the https keyword and tried it?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode