ARCHIVED: Quick guide for writing forms using Transform 3.0

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.
Note:

Due to the evolving coronavirus situation, the retirement of Webserve was delayed until April 16 to allow classes that reference sites on Webserve to continue with minimal disruption.

All remaining Webserve sites were disabled beginning April 16, along with login access to webserve.iu.edu. If you have websites that still need to be moved to IU Sitehosting, you should migrate immediately.

Note:
Transform will not be available on IU Sitehosting. If you are using Transform on Webserve, you will need to find another utility for processing HTML forms on IU Sitehosting.

On this page:


General information

Transform 3.0 was developed to make it easy for IU information providers to create working WWW forms without having to learn CGI programming.

Before using Transform, you must install it in your web account. Log into your web account and change to the directory where you will store your forms (for example, www/forms). At the prompt, type tf_install to install Transform. You should install Transform in every directory where you keep forms.

In order to create an online form using Transform 3.0, you will need two files, an HTML web form and a corresponding Transform template file.

  • Web form document in HTML: Much like any other HTML file, the web form document contains the HTML coding for your form. Visitors to the page will see a form where they can enter information. An online registration form, for example, might be called registration.html and would display various text fields and buttons.
  • Transform template file: The template file controls what happens to the results of a submitted form. The template file for the online registration form would probably be called registration.tpl. You can choose to have the data submitted through your form appended to a file or sent to you via email, or both, depending on what you put in the template file.

Each field in an HTML form has a name (for example, NAME = "question"). In the corresponding plain text Transform template file, you control where the value of a form variable (that is, the value entered by the user) is displayed by simply including the variable name in square brackets (for example, [question]).

Form appearance

Below is an image of a sample HTML form that might be used as a registration form. It allows users to select event options for which to register and submit contact information.

Screenshot of the Example of a Registration Form   sample event registration form

HTML source code for the form

Following is the HTML code for the Example of a Registration Form above. Copy and paste the following into a text editor, save it as an .html file, and then make any changes you need to customize the form for your needs. You will need to make the same changes in the template form, so if you change the name of a field in the HTML form file, you should make the same change in the template file.

  <HTML>
  <HEAD> </HEAD>
  <BODY>
  <CENTER> <FONT FACE="Arial"> 
  <TABLE BORDER="1">
  <TR>
  <TD>
  <CENTER> 
  <FONT FACE="Arial"> <B>Example of a Registration Form</B></FONT>
  </CENTER>
 
  <P> <FONT FACE="Arial">
  <FORM  METHOD="POST" ACTION="transform.cgi"> 
  <P> <FONT FACE="Arial"> Workshop and Panel Registration</FONT> </P> 
 
 
  <BLOCKQUOTE>
 
 
  <FONT FACE="Arial">
  <INPUT TYPE=checkbox NAME=box1 VALUE=checked> 
  Keynote Address<BR> 
  <INPUT TYPE=checkbox NAME=box2 VALUE=checked> 
  Panel One<BR> 
  <INPUT TYPE=checkbox NAME=box3 VALUE=checked> 
  Panel Two</FONT>
 
  </BLOCKQUOTE> 
 
  <P> <FONT FACE="Arial"> Gender</FONT> </P> 
 
  <BLOCKQUOTE>
  <FONT FACE="Arial">
  <INPUT TYPE=radio NAME=gender VALUE=Male> 
  Male<BR> 
  <INPUT TYPE=radio NAME=gender VALUE=Female> 
  Female</FONT> 
  </BLOCKQUOTE> 
 
  <P> <FONT FACE="Arial"> <TABLE BORDER=0> 
  <TR> 
  <TD>  
  <P> <FONT FACE="Arial"> Name:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial">
  <INPUT TYPE=text NAME=name VALUE="" SIZE=30> </FONT> </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> Email:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial">
  <INPUT TYPE=text NAME=email VALUE="" SIZE=30 MAXLENGTH=20> </FONT> </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> Address:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial"> <INPUT TYPE=text NAME=address VALUE="" SIZE=30> </FONT> </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> City:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial"> <INPUT TYPE=text NAME=city VALUE="" SIZE=30> </FONT>   </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> State/Province:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial"> <INPUT TYPE=text NAME=state VALUE="" SIZE=30> </FONT> </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> Postal/Zip Code:
  </FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial"> <INPUT TYPE=text NAME=zip VALUE="" SIZE=30> </FONT> </P> 
  </TD> 
  </TR> 
  <TR> 
  <TD> 
  <P> <FONT FACE="Arial"> Country:</FONT> </P> 
  </TD> 
  <TD> 
  <P> <FONT FACE="Arial"> <INPUT TYPE=text NAME=country VALUE="" SIZE=30> </FONT> </P> 
  </TD> 
  </TR> 
  </TABLE> 
  </FONT> </P> 
 
  <CENTER> <FONT FACE="Arial">
  <INPUT TYPE=submit NAME=Submit VALUE="Submit Form"> </FONT> </CENTER> 
  </FORM> </FONT> </P>

Template file code

Copy and paste the following into a text file. You should save it in the same directory where your form is kept, and it should have the same name and a .tpl file extension. (If your form is called registration.html, then save this file as registration.tpl so that the template and its form will have the same name.) Make sure to change username to your username.

  *define-variables* 
  [req-email]
  [req-name]
  [req-address]
  [req-city]
  [req-state]
  [req-zip]
 
  [gender]
  [box1]
  [box2]
  [box3]
  [country]
  *email-response*
  !use-if [Submit] eq "Submit Form"
  To: username@indiana.edu,[email]
  From: [email]
  Subject: [name] - Registration Form
 
  [!DATE]
 
  [name] has registered.
 
  !print-if [gender] eq "Male"
  Gender is male.
  !print-if [gender] eq "Female"
  Gender is female.
  !end-print-if
 
  !print-if [box1] eq "checked"
  Will attend Keynote Address.
  !print-if [box2] eq "checked"
  Will attend Panel One.
  !print-if [box3] eq "checked"
  Will attend Panel Two.
  !end-print-if
 
 
  Below is [name]'s contact information and mailing address:
  -----------------------------------------------------------------------
  [name] 
  [email]
  [address]
  [city], [state] [zip]
  [country]
  -----------------------------------------------------------------------
  --end of message--
  
  *success-response*
  !use-if [Submit] eq "Submit Form"
  <HTML><head><title>Registration Form Success Response</title></head>
  <body bgcolor="#FFFFFF">
  <h2> <center> Thanks, your registration form has been submitted.</center> </h2><p>
  <p>
  <p>
  <p> 
  The following information was submitted with your registration:<br> 
  (you may wish to print this page for your personal records)<br>
  <hr> 
 
  !print-if [gender] eq "male"
  Gender is male<br>
  !print-if [gender] eq "female"
  Gender is female <br>
  !end-print-if
  <blockquote>
  !print-if [box1] eq "checked"
  Will attend Keynote Address <br>
  !print-if [box2] eq "checked"
  Will attend Panel One <br>
  !print-if [box3] eq "checked"
  Will attend Panel Two <br>
  !end-print-if
  </blockquote> 
  <p>
  Name: [name]<br>
  Email: [email]<br>
  Address: [address]<br>
  City: [city]<br>
  State/Province: [state]<br>
  Postal/Zip Code: [zip]<br>
  Country: [country]<br> 
  !end-print-if
  </body></html>
 
  *error-response*
  !use-if [Submit] eq "Submit Form"
  <HTML> <head> <title>Registration Request Error</title></head>
  <body bgcolor="#FFFFFF">
  <h2><center>Sorry, there was an error submitting your online 
  registration.</center></h2> <p>
  You have not included the following required information in your request:
  <p>
  !print-if [name] eq ""
  NAME:<br>
  !print-if [email] eq ""
  EMAIL:<br>
  !print-if [address] eq ""
  ADDRESS:<br>
  !print-if [city] eq ""
  CITY:<br>
  !print-if [state] eq ""
  STATE/PROVINCE:<br>
  !print-if [zip] eq ""
  ZIP:<br>
  !end-print-if
  <p>
  Please GO BACK to the Registration Form and re-submit it with all of
  the required registration information.
  </body>
  </html>
 
  *append-response*
  !use-if [Submit] eq "Submit Form"
  !append-file-name = "/ip/username/www/filename.txt"
  [!DATE],[name],[email],[address],[city],[state],[zip],[country],[gender]

This is document bfsv in the Knowledge Base.
Last modified on 2021-09-08 10:22:18.