Like most Authorware developers, I found the
distinction between ReadURL() and PostURL() to
be a little fuzzy until I started doing more straight
HTML work.
If you look at the FAQ
page of my site, you will find the form where
you signed up for this list. If you view the source
of that page, you will find the line <FORM
action="http://pub45.bravenet.com/elist/add.php"
method="post">. This is the opening
tag of a form.
What it tells the browser is that when the form
is submitted, send the contents of the form directly
to "add.php." When the php page gets this information,
it is in no way visible to the user (in other
words, it does not show up in the URL).
What are the contents of the form, then? Between
the Form open and close tags, you will see several
lines that look something like this <input
type="text" name="ename" size="25"
maxlength="60"/> . This tag means that
the php page will receive the contents of that
text field as a variable called ename.
In the php page, this value will be contained
in $HTTP_POST_VARS['ename'].
In the more familiar asp, that would be Request.Form("ename").
The php page then communicates with the database
and adds the new user to the mailing list.
When you use PostURL(), Authorware is basically
pretending to be an HTML form with a post
method. The back-end page (asp, php, cfml, cgi,
or whatever) does not know or care how that information
was sent.
If you need information back from the
database, the back-end page will need to send
a response. In PHP, this looks like <?php
print $QueryResults; ?>. In ASP, it
would be Response.Write QueryResults.
So, what all this means is that when you use
Myvar := PostURL("http://www.myserver.com/myfile.asp",
"username="^UserName, 20), what you are
saying is send UserName to the asp page as if
it came from a form field called "username" and
wait for 20 seconds to see if the asp page has
any feedback based on UserName. If there is, put
that feedback in MyVar. Depending on what the
asp page is designed to do, this can be "ok",
a list of previous results for this user in this
course, or his address.
So what about ReadURL()? ReadURL cannot communicate
directly with the back-end page, so you must add
anything you want to tell the page to the end
of the URL. This is equivalent to a "get" form
method. So you would use Myvar
:= ReadURL("http://www.myserver.com/myfile.asp?username="^UserName,
20). However, you cannot expect that the
page will react identically to the two statements.
This is because the value of username can't be
read from the same place at the back-end page.
In php, this will be $HTTP_GET_VARS['username'],
while in asp this would be Request.QueryString("username").
For more information on php, try PHP
from the Ground Up. For more on asp, look
at Your
First Database.