
WEB·FM uses the ACTION attribute in the FORM element to specify the name of the target FileMaker Pro database to receive the form contents. Including a ".fm" suffix on the end of the database name in the URL will flag the web server in recognizing the request as a database transaction to be handled by WEB·FM. Although recommended that the actual database file name optionally have a ".fm" suffix, it's not required. Still, if you store the database in the web server directory tree, then it is a good idea to name the database with a ".fm" suffix for security reasons.
Because space characters in a URL are illegal, and many database documents include spaces in their name, it's important that we replace these space characters, if any, in the URL with a "+" character.
Example:
<FORM METHOD="POST" ACTION="database+name.fm">
In a form you can include INPUT, SELECT, and TEXTAREA tags to specify fields and their interface elements. As you create a form, your primary task is to decide which database fields you want WEB·FM to handle, then place INPUT elements in your form that match the names of those database fields.
IMPORTANT NOTE The field names in the database that you want to Find on or Add to must match EXACTLY the INPUT elements on your FORM. If the INPUT elements on a form do not match the database field names EXACTLY (spelling and punctuation) WEB·FM will not be able to map values to database fields.
An INPUT element of type "submit" is a pushbutton that causes the current form contents to be packaged into a string of "name=value" pairs and sent to an origin web server. WEB·FM expects the name (not the value) of the submit pushbutton to match the command desired for the form. When the name of the submit button is not recognized as a valid command, WEB·FM will default to performing a Find request using the submitted form values. Legal commands are:
Find
FindAll
FindUser
Retrieve
Random
Add
Update
Delete
TIP "A 'submit' element is required in all forms except those containing only a single INPUT element of type TEXT (in which case Return in the text entry area submits the form) or at least one INPUT element of type IMAGE (in which case a click in the image submits the form)."
Begin your form with standard DOCTYPE, HTML, HEAD, and BODY elements and follow with a FORM element that specifies the target database.
Example:
<FORM METHOD="POST" ACTION="EdExpert.fm"> ... </FORM>
Next, place inside the form variables for returning the contents of the 'header', 'footer', 'html' database fields to the web.
<INPUT TYPE="hidden" NAME="header" VALUE="header">
<INPUT TYPE="hidden" NAME="footer" VALUE="footer">
<INPUT TYPE="hidden" NAME="html" VALUE="html">
Next, place inside the form variables for sorting all found records, while returning only a few.
<INPUT TYPE="hidden" NAME="sort" VALUE="last name">
<INPUT TYPE="hidden" NAME="max" VALUE="10">
Next, place inside the form INPUT elements for fields you wish to search on. The following HTML allows a user to search the ExExpert.fm example database by username and company.
Example: Name:
<INPUT NAME="username" VALUE=""> Company:
<INPUT NAME="company" VALUE=""> Specify the Find command in the NAME attribute of the 'submit' pushbutton. Example:
<INPUT TYPE="submit" NAME="Find" VALUE="Submit"> The form you just created allows a user to search by name and company. It then sorts all found records, returning HTML from a maximum of 10 records. Finally, in case no records are found we need to include the Error variable with a value for an error Template file located on disk in the same relative directory as the current URL.
<INPUT TYPE="hidden" NAME="error" VALUE="error.html">
Relational fields must be referred to by a special name that begins with the name of the database relationship, followed by two colons "::" and the actual field name.
Example:
<INPUT TYPE="hidden" NAME="layout" VALUE="layout name">
<INPUT NAME="relationship::field name" VALUE="">
N O T E The relationship name is NOT the name of the related database. It is the name you gave the relationship in the "Define RelationshipsÉ" dialog. (For more information, refer to the FileMaker Pro documentation on relational fields).
Example:
<INPUT TYPE="hidden" NAME="sort" VALUE="city">
TIP For performance reasons, WEB·FM does not always show a found set of records in the database unless a sort or script is required. To force showing all records found without actually sorting, include the Sort variable but without a field name value.
Sorting found records in ascending or descending order is possible by including the variable Sortorder in a form with a value of "ascending" or "descending". As mentioned before, since WEB·FM sorts records in ascending order by default, it is only necessary to use this variable if you need to sort in "descending" order.
<INPUT TYPE="hidden" NAME="sortorder" VALUE="descending">
TIP Refer to Chapter 8: Processors for information on using a Filter processor to filter incoming requests using an alternate to the sortorder variable of "sort=up" or "sort=down".
<INPUT TYPE="hidden" NAME="html" VALUE="html">
After a successful Find, the contents of the field "html" are returned by WEB·FM from each record found. After submitting the search form the web browser will display what is commonly referred to as a "hit list" of found records. The HTML returned to the web browser is the result of FileMaker Pro evaluating the field's calculation formula for each record. The formula includes normal text, HTML tags, and most importantly the values from other database fields who's information is desired. This is accomplished by concatenating fields in the formula with HTML.
The simplest formula for a basic "html" field utilizes the Retrieve command and might look something like this example: "
<LI><A href='EdExpert.fm$retrieve?RecNum=" & RecNum & "&html=detail.html'>" & Company & "</A><P>"
It's often better to return only a range of found records rather then all records found with a successful find. Use the variable Max in your form with a numeric integer value equal to the maximum number of records you wish to return with a single database Find.
Example:
<INPUT TYPE="hidden" NAME="max" VALUE="10">
Refer to the section on [token] support for information on including a "Next Page" link for displaying the next or previous [max] set of found records.
Example:
<FORM METHOD="POST" ACTION="Database+Name.fm">
Next, include INPUT elements that match exactly the field names in the FileMaker Pro database that you are working with.
Example:
Name: <INPUT NAME="first name" VALUE=""><P>
Company: <INPUT NAME="company" VALUE=""><P>
Tell WEB·FM what action to perform by naming the submit pushbutton "Add".
Example:
<INPUT TYPE="submit" NAME="Add" VALUE="submit">
It's always a good idea to target a specific database layout for creating a new record. Performance will be improved because WEB·FM will only have to interface with a small subset of database fields (those on the target layout) and not all fields in the entire database. The layout variable you place on your fill-out FORM will look something like this:
<INPUT TYPE="hidden" NAME="layout" VALUE="layout name">
It's important to include on your form the HTML variable for specifying a Template file containing a response page. In the case below, WEB·FM will return a Template file for a detail confirmation page with record values dynamically substituted.
Example:
<INPUT TYPE="hidden" NAME="html" VALUE="detail.html">
The complete submission form might look like this:
<FORM METHOD="POST" ACTION="EdExpert.fm ">
<INPUT TYPE="hidden" NAME="layout" VALUE="data entry">
<INPUT TYPE="hidden" NAME="html" VALUE="detail.html">
Name: <INPUT NAME="first Name" VALUE=""><P>
Company: <INPUT NAME="Company" VALUE=""><P>
<INPUT TYPE="submit" NAME="add" VALUE="submit">
</FORM>
Having created the two most basic (and most often used) forms, let's take a look at some ways WEB·FM allows you to include greater functionality.
Should an INPUT element be submitted with no value when data validation for this field is enabled in the database, WEB·FM will not create the record and instead return a basic validation error message.
Example:
<INPUT NAME="relationship::field name" VALUE="">
If multiple values for a portal field are received, WEB·FM will create a new portal row for each value.
Example:
<INPUT TYPE="hidden" NAME="browser" VALUE="[browser]">
<INPUT TYPE="hidden" NAME="domain" VALUE="[domain]">
<INPUT TYPE="hidden" NAME="customer" VALUE="[cookie]">
Use the FindUser command to return an update form with existing record information. By using FindUser, this update form is not returned unless the user has a valid username and password, or browser "cookie" value.
Example:
<A href="EdExpert.fm$FindUser?layout=data+entry&html=update.html">
If you expect more than one record to be found with FindUser, you should return a "hit list" of found records from the database first, and then select the desired record from this list using a record number identifier.
Example:
<A href="EdExpert.fm$FindUser?RecNum=2&layout=data+entry&html=update.html">
Use the Update command on a form if you wish to modify an existing database record with submitted form values. The Update command is equivalent to the Add command, only a new record is not created. Instead, WEB·FM performs a find for a single record, then verifies authorization to update this record. If authentication checks pass, submitted form values will replace existing cell values in the found record.
W A R N I N G Submitting INPUT elements with values that are empty will DELETE existing database cell values.
To Update an existing database record WEB·FM must first find the correct record to update. An update form should contain the following INPUT variables. If no Field and Value variables are specified, WEB·FM still attempts to find the correct record using the username and password, or browser cookie value. In this case, though, [RecID] is a token which gets replaced with the record identifier when the update form is initially retrieved. You may use RecID or the name of another serial number field for the unique record identifier.
<FORM METHOD="POST" ACTION="Database+Name.fm ">
<INPUT TYPE="hidden" NAME="field" VALUE="RecID">
<INPUT TYPE="hidden" NAME="value" VALUE="[RecID]">
<INPUT TYPE="hidden" NAME="layout" VALUE="layout name">
<INPUT TYPE="hidden" NAME="html" VALUE="detail.html">
<INPUT TYPE="submit" NAME="update" VALUE="submit">
<FORM>
Unless you have the administrator password, it is not possible to edit an existing record without first creating new "username" and "password" (or "cookie") fields. Authorization to update is given if the request passes one of the following checks.
Be very careful when updating portal fields. WEB·FM will replace existing portal field values with new values in the order sent by the web browser. There is real potential to edit an incorrect portal row, so test carefully with different browsers before deploying a solution that requires editing existing portal rows.