semi-OT: can Rev pre-populate data on a web form?

Jim Ault JimAultWins at yahoo.com
Fri Sep 5 15:58:58 EDT 2008


Ben is right on the mark with the 'submit a form' directly from Rev, but one
caveat may be that your website setup software may be using a pre-fab
browser detection script for maximum platform compatibility.  If this is the
case, Revolution will not look like any of the browsers, like FireFox,
Safari, Explorer and it may simply ignore your form submission.

There are ways to deal with this, so post a message if Ben's advice does not
work out.  The browser detection is often done with javascript between the
<header> tags.  The browser detection is important for Flash content.

Hope your form goes smoothly

Jim Ault
Las Vegas


On 9/5/08 2:28 AM, "Ben Rubinstein" <benr_mc at cogapp.com> wrote:

> Chris Sheffield wrote:
>> So my main question is, can Rev send data to a web form like this in
>> such a way that whatever fields we specify will be populated when the
>> browser/form opens? Not sure if something like this is even possible. I
>> haven't done enough web development to know. Is some special JavaScript
>> required to accomplish this? In thinking this through a little more, if
>> we have a web form that's already set up to send an email, can't I take
>> advantage of that in Rev by creating my own form and then sending the
>> data straight to the cgi behind the form? Once again, I haven't done
>> much web dev, so I may not even know what I'm talking about. :-)
>> 
>> If anyone can help or can offer any other suggestions for how to
>> accomplish something similar, it'd be much appreciated.
> 
> 
> If I've understood your request correctly, you really want a Rev stack to
> collect some information from the user, and have it arrive at your server in
> the form of an email.  There's a simple way to get what you want, I think.
> 
> Using the SMTP libraries should make this possible, but has some issues, in
> particular your rev stack then needs to know the address of a mail server it
> can use from within the user's network to send email.  But if you have a web
> form on your server that's successfully sending email where you want it,
> there's no need to open a user's browser to view it.  Instead, Rev can
> effectively be that web form.
> 
> (Apologies if what follows is teaching my granny to suck eggs.) If you look at
> the source of the web page, it will contain a "form" element with an action
> and a method.  The action is the address of a server-side resource (a script
> etc) which receives the values entered into the form and processes it, in this
> case by sending an email.  The method is either POST or GET.  If it's GET,
> then the resource expects the values in the URL string, eg if I fill in this
> simple form
> 
> <form method="GET" action="formmail.cgi">
> <input name="first" type="text">
> <input name="last" type="text">
> <input type="submit" />
> </form>
> 
> my browser will next fetch a URL like this:
>    ...../formmail.cgi?first=Ben&last=Rubinstein
> 
> (the first part of the URL being constructed based on the URL of the page
> holding the form, adjusted by the 'action' of the form.)
> 
> Lecture over; the point is that executing
> 
> put "...../formmail.cgi?first=Ben&last=Rubinstein" into tURL
> get URL tURL
> 
> or perhaps more likely
> put "...../formmail.cgi" into tScriptURL
> put tScriptURL \
>              & "?first=" & tFirstName \
>    & "&last=" & tLastName \
>    into tURL
> get URL tURL
> 
> 
> 
> in your Rev stack will have exactly* the same effect on the 'formmail.cgi'
> resource as the user entering those details into their browser.  At this point
> Rev is acting like a browser, making a request of the web server.  So no need
> to open an actual browser.
> 
> If the form uses the POST method instead, then it's only slightly more
> complicated.  Instead of get URL, you need to use the "post" command, which
> will look something more like this:
> 
> put libURLformData("first", tFirstName, "last", tLastName) into tData
> post tData to tScriptURL
> 
> There will be a few complications along the way; you should read the
> (splending new in 3.0) docs, check out functions like URLencode, and above
> all, test.  But either way, given that you have the web form already, this is
> probably the simplest route to achieve what you want.
> 
> HTH,
> 
> - Ben
> 
> 
> *pedants please leave now
> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list