I need to collect information from a large number of people.
Step 1: Prepare your computer account with AMS
Step 2: Create a Web form and
create a database to
hold the data from the form. Remember, the database field names must
be the same names you are using in the form. The database can have more
fields than are in your form, but each element of the form must have
a corresponding field in the database with the same name.
Step 3: Write the ColdFusion scripts that will process the data
from the form. There is an application.cfm file for security, a script
that will take the data from the form and put it into the database (populate
the database), and a third script that will display the contents of the
The application.cfm file can look like this:
<!--- Set application constants _--->
The script that populates the database is called update.cfm and
can look like this:
<cfif '#name#' is "" or
'#color#' is "" or '#age#' is "" or '#vacation#'
Please use the browser back button and fill out every form field.
<cfelseif isnumeric(form.age) is "no">
Please use the back button and enter a number for your age!
<cfquery name="addinginfo" datasource="teamweb_surveyclass" username="#application.teamweb_surveyclass_username#" password="#application.teamweb_surveyclass_password#">
insert into form
<h1>New record added to database</h1>
Record <b>#name#</b> added.
The script that displays
the database contents is called show.cfm and can look like
<CFQUERY name="x1" datasource="teamweb_surveyclass" username="#application.survey_class_username#" password="#application.survey_class_password#">
SELECT * from form
<table border="1" cellpadding="4" cellspacing="4">
<th>Favorite Vacation Spot</th>
Step 4: Put my web form on a web page and ask folks to fill it
Step 5: When people click submit, the "action" variable
in the form tag calls update.cfm. Update.cfm takes the data from
the form and puts it into the database. The form tag looks like:
<form name="create" method="post" action="http://web.austin.utexas.edu/pathtoscript/update.cfm">
Data Checking: I want to make sure the name and age fields are
not blank and that what they've put as their age is, in fact, numeric
between 5 and 55. I perform these validations in the form by adding a
hidden field to each field that I want to test. For example, to make
sure the name field is not blank I add a second input tag:
<input type="text" name="name">
<input type="hidden" name="name_required" value="Please
enter your name">
The following input tags will verify that the age field is not blank
and is numeric between 15 and 55:
<input type="hidden" name="age_required" value="Please
enter your age">
<input type="hidden" name="age_integer" value="Please
enter your age">
<input type="hidden" name="age_range" value="min=15
ColdFusion has seven basic validation rules:
||Date in most common formats like MM/DD/YY and MM/DD/YYYY
||Date as DD/MM/YY
||Numeric data, decimal point allowed
Numeric data, decimal point not allowed.
||Range of values, the minimum and maximum values (or just one of
them) must be specified in the VALUE attribute as MIN= and MAX=,
for example, "MIN=5 MAX=10"
||Field is required and may not be left blank.
||Time in most common time formats.
Step 6: I want to display the contents of the database on a Web
page. The script that does that is called show.cfm.
Step 7: To perform data analysis, I will import this Microsoft
Access database into SAS or SPSS. If you need assistance with this step,
the ITS Statistical Support Web
site is available. In addition, consulting is
A sample Microsoft Access database can be downloaded
for you to examine. (Download MS Access Viewer)