Page 1 of 1

Server Response.

Posted: Thu Jul 14, 2011 8:37 pm
by Kaubs
What I am trying to do : A user enters username and password into fields. The app collects this data and sends it to the server. I am using some examples I have found and everything seems to work great. I cannot seem to find however...in the dictionary or tutorials, a way to create an if statement for a server response. The server will respond with a simple 1 or 0. The server is currently being set up so I cannot test with a live URL. Here is what I have thus far.

Code: Select all

on mouseUp
   put fld "username" into tUNA
   put fld "password" into tPWA
   put "http://" & tUNA & ":" & tPWA & "\" & "@www.example.net/index.html" into compiled
 saveUNandPW
end mouseUp

command saveUNandPW
   put specialfolderpath("documents") & "/text.txt" into tFile
   put compiled into url("file:" & tFile)
      go to card 3 
end saveUNandPW
Would it be something as simple as?

Code: Select all

on mouseUp
   put fld "username" into tUNA
   put fld "password" into tPWA
   put "http://" & tUNA & ":" & tPWA & "\" & "@www.example.net/index.html" into compiled
## post command inserted here with proper URL and above example.net changed
##in theory after post completes
if response from server is 1 then
continue
else
##report error here
 saveUNandPW
end mouseUp

command saveUNandPW
   put specialfolderpath("documents") & "/text.txt" into tFile
   put compiled into url("file:" & tFile)
      go to card 3 
end saveUNandPW
Thx for any help guys!

Re: Server Response.

Posted: Thu Jul 14, 2011 10:48 pm
by Jellicle
From memory the post command returns a value either in the result, or in it. So:

if the result = 1 then
danceAjig
else
sulkAllDay
end if

or...

if it = 1 then
danceAjig
else
sulkAllDay
end if

Gerry

Re: Server Response.

Posted: Fri Jul 15, 2011 6:29 pm
by Kaubs
Thx! "it" is the correct statement.

post whatever to url "http://someplace.com/php.login/"
if it is "baboon" then
fly a kite
else
so on and so on
end if