Revelation Enterprises

Getting Started with Custom Web Publishing:
Building a Simple Site Using CDML

The following article is reprinted from the pages of FileMaker TechInfo Knowledgebase.
The article is reprinted in its entirety, and Revelation Enterprises makes no warranties,
whether express or implied, as to the validity of the content of this article.

This article may be located in FileMaker TechInfo at this address:

http://www.filemaker.com/ti/104560.html

This tutorial will show you how to use custom web publishing to set up and host, on an intranet, a very simple sample database and associated web pages. This example will allow entry of records into your database via browser and will return confirmation that the information was entered successfully. The example is designed to pull together information from all of the other web-publishing information sources (see the Next Steps section below) to help you quickly assemble a working model.

After you have completed the sample solution, you will have the foundation on which to build your site. Once your site has been successfully hosted on your intranet, it is ready for the World Wide Web. Please see the related article for all the information you will need to host your database system on the World Wide Web.

Note: You will need to be familiar with HTML and the basics of Web publishing, in general, in order to create a custom Web site.

How it works:
FileMaker Pro 4.0 includes a Web Companion component that allows your computer to become a Web server; it also contains a CGI that allows Web pages to interact with a FileMaker Pro 4.0 database. Your database itself is not visible on the Web; rather, information is sent to or retrieved from it by means of special FileMaker Pro 4.0 code called CDML. You can host a FileMaker Pro 4.0 database over the Web using Built-in Web Publishing, or you can create a custom site by incorporating CDML into your own HTML pages.

Step-by-step instructions for creating a simple Web-accessible database solution:
1. In FileMaker Pro 4.0:
• Create a database called "basic.fp3" (without quotes) and define three fields: field1, field2, and field3. Leave this file open.

2. In any word- or text- processing application:
• Create a new document. This first page will hold the bare essentials for accessing your database via the Web. In this page, you will call on the FileMaker Pro 4.0 CGI, identify the database and fields to interact with, tell the Web server what to do with the information entered, and specify a response page and a page to display if there is a data entry error.
*** Note: Aside from Claris Home Page 3.0, do not use graphics-based HTML authoring software; these programs will strip proprietary tags (such as CDML) from your document.

To create this initial page, type the following code:
<HTML>
<HEAD>
<TITLE> Quick Test</TITLE>
</HEAD>
<BODY>

<P>Enter a new record</P>

<FORM ACTION="FMPro" METHOD="POST">
<INPUT TYPE="hidden" NAME="-db" VALUE="basic.fp3">
<INPUT TYPE="hidden" NAME="-format" VALUE="response.htm">
<INPUT TYPE="hidden" NAME="-lay" VALUE="Layout #1">
<INPUT TYPE="hidden" NAME="-error" VALUE="error.htm">

<P>Field 1: <INPUT TYPE="text" NAME="field1" SIZE=20></P>
<P>Field 2: <INPUT TYPE="text" NAME="field2" SIZE=20></P>
<P>Field 3: <INPUT TYPE="text" NAME="field3" SIZE=20></P>

<P><INPUT TYPE="submit" NAME="-new" VALUE="submit"></P>

</FORM>
</BODY>
</HTML>

• Save your page as Text into the Web directory/ folder that is in the same directory/folder as the FileMaker Pro 4.0 application, and name it “welcome.htm” (without the quotes).

• Create a second HTML page with the code below; this will be your response page (referred to in CDML as the "format" page):

<HTML>
<HEAD>
<TITLE> Response</TITLE>
</HEAD>
<BODY>
<P>Thank you</P>
</BODY>
</HTML>

• Save this page as Text into the same directory/folder, with the filename “response.htm”.

• Create a page called "error.htm" with the following code and save it into the Web directory/ folder. This page will be returned if there is an error in data entry.

<HTML>
<HEAD>
<TITLE> Error</TITLE>
</HEAD>
<BODY>

<P>Error! Please go back!</P>
</BODY>
</HTML>

3. Prepare to view your solution:
• Activate the Web Companion in FileMaker Pro 4.0:
--Enable the Web Companion in Preferences/ Application/ Plug-Ins.
--Under the File menu, choose Sharing, then check the box to enable the Web Companion.
--Under Preferences/ Web Companion, click Configure, then specify “welcome.htm” as the Home Page.

•Find out your computer’s IP address:
--Mac OS: Under the Apple menu, choose Control Panels, then TCP/IP.
--Windows 95/ NT: From the Start menu, choose Settings/ Control Panels/ Network. Then click on the TCP/IP item (in Windows NT only, first click the Protocols tab), then click Properties.

• Launch your Web browser and enter your IP address into the Location box. Note that you cannot simply open the file in your browser as you would an ordinary HTML page; you must actually hit the server (i.e., your machine) in order to access a FileMaker Pro 4.0 database.

4. Test your database:
• You should see your custom page with your fields. Enter some information into the fields, then click the Submit button. You should receive the “Thank You” response page. Check your database to see the new record you just created (it may not be the active record).
• Enter your machine's IP address into the browser of another computer on your intranet network and try this.

Troubleshooting
If you have trouble making this example work:
--Check your spelling, syntax, and punctuation
--See the manual, Chapter 11
--See the online Help
--See the CDML Reference, Developer’s Guide tab

Next steps:
Now that you have the basics of setting up a database for custom Web publishing, you are ready to explore the possibilities. Suggested things to do next:

--Examine the sample solutions in the Web folder (in order of complexity: Guest Book, Employee Database, and Shopping Cart)
-- Look at the CDML Templates in the Web Tools folder; they will step you through creation of other basic pages you are likely to want.
-- Read the CDML reference
--Experiment with the CDML Tool, which lets you copy and paste CDML code so you don’t have to remember syntax or type the code. It will also help you avoid making typographical errors that may be time-consuming to troubleshoot.

TechInfo Knowledge Base may contain articles about products that are no longer supported by FileMaker, Inc. Product support is provided for the currently shipping version, and one version back. Products, services or technical information provided by FileMaker, Inc. are subject to change without notice.

THIS DOCUMENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, AND FILEMAKER, INC. DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THE WARRANTY OF NON-INFRINGEMENT. IN NO EVENT SHALL FILEMAKER, INC. OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS, PUNITIVE OR SPECIAL DAMAGES, EVEN IF FILEMAKER, INC. OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY. FILEMAKER MAY MAKE CHANGES TO THIS DOCUMENT AT ANY TIME WITHOUT NOTICE. THIS DOCUMENT MAY BE OUT OF DATE AND FILEMAKER MAKES NO COMMITMENT TO UPDATE THIS INFORMATION.