Accessing the Database

Terra Flora has an existing table in its order database. This table is used to process retail orders. The ability to access existing stores of information is the primary benefit of using Internet Information Server at Terra Flora.

Users enter data into the database by using an HTML form, as shown in the .htm file in Figure 5.17.


<HTML> <HEAD> <TITLE>Terra Flora</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <H1 Align = "Center"><CENTER><FONT SIZE=6 COLOR=#000000 FACE="Arial">Terra Flora Order Desk</FONT><FONT SIZE=6> </FONT></CENTER></H1> <FORM ACTION="/secure/Order.idc" METHOD = "POST"> <P> <TABLE BORDER=2 BORDER BGCOLOR="#FFFFFF"> <TR><TD>FirstName</TD><TD><INPUT NAME="FirstName" VALUE="" &lt;/TD> </TD><TD><BR> Address1</TD><TD><A NAME="UQHTML0"></A><INPUT NAME="Address1" VALUE="" &lt;/TD> </TD></TR> <TR><TD>LastName</TD><TD> <INPUT NAME="LastName" VALUE="" &lt;/TD> </TD><TD><BR> Address2</TD><TD><INPUT NAME="Address2" VALUE="" &lt;/TD> </TD></TR> <TR><TD>ProductId1</TD><TD><INPUT NAME="ProductId1" VALUE="" &lt;/TD> </TD><TD> <BR> City</TD><TD><INPUT NAME="City" VALUE="" &lt;/TD> </TD></TR> <TR><TD>ProductId2</TD><TD><INPUT NAME="ProductId2" VALUE="" &lt;/TD> </TD><TD> <BR> State</TD><TD><INPUT NAME="State" VALUE="" &lt;/TD> </TD></TR> <TR><TD>ProductId3</TD><TD><INPUT NAME="ProductId3" VALUE="" &lt;/TD> </TD><TD> <BR> Country</TD><TD><INPUT NAME="Country" VALUE="" &lt;/TD> </TD></TR> <TR><TD>Comment</TD><TD><INPUT NAME="Comment" VALUE="" &lt;/TD> </TD><TD>PhoneNumber</TD><TD> <INPUT NAME="PhoneNumber" VALUE="" &lt;/TD> </TD></TR> <TR><TD>DeliveryDate</TD><TD><INPUT NAME="DeliveryDate" VALUE="" &lt;/TD> </TD><TD>Email</TD><TD> <INPUT NAME="Email" VALUE="" &lt;/TD> </TD></TR> <TR><TD>CreditCardNumber</TD><TD><INPUT NAME="CreditCardNumber" VALUE="" &lt;/TD> </TD><TD> <INPUT TYPE="SUBMIT" VALUE="Place Order" ALIGN="MIDDLE"></P> </TD><TD><INPUT TYPE="RESET" NAME="reset" VALUE="Clear" ALIGN="MIDDLE"> </TD></TR> </TABLE> <P> </FORM> <P> <HR=2> </BODY> </HTML>

Figure 5.17 Sample .htm file for Terra Flora order desk

Figure 5.18 shows the results of this .htm file in Internet Explorer.

Figure 5.18 Terra Flora order desk file displayed by Internet Explorer

When a user clicks the Place Order button, the data is processed by using the .idc file shown in Figure 5.19.


Datasource: OrderDB Template: Order.htx SQLStatement: +INSERT INTO "OrderDB" ("FirstName", "LastName", "Email", "PhoneNumber", "CreditCardNumber",
+"Address1", "Address2", "City", "State", "Country", "ProductId1", "ProductId2",
+"ProductId3", "Comment", "DeliveryDate") +VALUES ('%FirstName%', '%LastName%', '%Email%', '%PhoneNumber%', '%CreditCardNumber%',
+'%Address1%', '%Address2%', '%City%', '%State%', '%Country%', '%ProductId1%', '%ProductId2%',
+'%ProductId3%', '%Comment%', '%DeliveryDate%'); #IDC-Insert FrontHTM-default.htm ReportHTX-Order.htx

Figure 5.19 Sample .idc file for Terra Flora order desk

The .idc file then posts the information to the database and results are formatted by using the .htx file specified in the .idc file, Order.idc, as shown in Figure 5.20.


<HTML> <HEAD> <TITLE>Submitted Order</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <P> <B>Verify this posted information with the customer.<BR> </B> <P> <TABLE BORDER=2 BORDER BGCOLOR="#FFFFFF"> <TR><TD ALIGN="RIGHT"><B>FirstName</B></TD><TD><%IDC.FIRSTNAME%> </TD><TD ALIGN="RIGHT"><B>Address1</B></TD><TD><%IDC.ADDRESS1%> </TD></TR> <TR><TD ALIGN="RIGHT"><B>LastName</B></TD><TD><%IDC.LASTNAME%> </TD><TD ALIGN="RIGHT"><B>Address2</B></TD><TD><%IDC.ADDRESS2%> </TD></TR> <TR><TD ALIGN="RIGHT"><B>ProductId1</B></TD><TD><%IDC.PRODUCTID1%> </TD><TD ALIGN="RIGHT"><B>City</B></TD><TD><%IDC.CITY%></TD></TR> <TR><TD ALIGN="RIGHT"><B>ProductId2</B></TD><TD><%IDC.PRODUCTID2%> </TD><TD ALIGN="RIGHT"><B>State</B></TD><TD><%IDC.STATE%></TD> </TR> <TR><TD ALIGN="RIGHT"><B>ProductId3</B></TD><TD><%IDC.PRODUCTID3%> </TD><TD ALIGN="RIGHT"><B>Country</B></TD><TD><%IDC.COUNTRY%> </TD></TR> <TR><TD ALIGN="RIGHT"><B>Comment</B></TD><TD><%IDC.COMMENT%></TD><TD
ALIGN="RIGHT"><B>PhoneNumber</B> </TD><TD><%IDC.PHONENUMBER%></TD></TR> <TR><TD ALIGN="RIGHT"><B>DeliveryDate</B></TD><TD><%IDC.DELIVERYDATE%> </TD><TD ALIGN="RIGHT"><B>Email</B></TD><TD><%IDC.EMAIL%></TD> </TR> <TR><TD ALIGN="RIGHT"><B>CreditCardNumber</B></TD><TD><%IDC.CREDITCARDNUMBER%> </TD><TD></TD><TD></TD></TR> </TABLE> <P> <P> <A HREF="/default.htm">Return To Data Entry Page</A> <P> </BODY> </HTML>

Figure 5.20 Sample .htx file for Terra Flora order desk

The process is complete when the database returns confirmation through the .htx file, as shown in Figure 5.21.

Figure 5.21 Terra Flora order desk confirmation .htx file in Internet Explorer