HOWTO: Processing XForms data on a server

This tutorial is for people who are familiar with the basics of XForms, have knowledge of some server-side processing langauge, and want to combine the two. In this section we'll look at how to do this with PHP, ASP, Java Servlets and ColdFusion.

To run the examples in this document you will need to have installed formsPlayer. For the ColdFusion example you should have installed and configured ColdFusion 6.1. The ASP example requires IIS and the Java Servlet example requires Jakarta Tomcat or an equivalent. The PHP example was tested with PHP version 4.3.7 and IIS.

The source for the form and the server-side scripts is available from here.

The sample XForm

The examples that are listed in this document all use the same simple XForm. It contains only one XForms model and one set of instance data. The XForm holds a few pieces of information about a person such as their name, age, gender, address, etc. The full instance data is as shown below:

<person xmlns="">
  <firstname>Joe</firstname>
  <surame>Bloggs</surame>
  <gender>M</gender>
  <age>32</age>
  <phone>02085555555</phone>
  <email>joe.bloggs@example.com</email>
  <address>
    <addr1>1a Street</addr1>
    <addr2>A Town</addr2>
    <addr3>A City</addr3>
    <addr4>Post Code</addr4>
  </address>
</person>

Each piece of instance data is referenced by a single XForms control. The XForms data is submitted to a resource by using the submission element. For the ASP example the submission element will look something like this (depending on the structure of your IIS site):

<xf:submission id="sub-save-person"
  method="post" action="http://localhost/EchoPerson.asp" 
/>

NOTE: Although the same XForm is used in each example in the following sections, you will need to change the submission elements' action attribute for each one so that the form data is submitted to the correct resource.