The Steps For Operation:
Adapting Your HTML Form for Connecting with sord.cgi
Optional Internal Variables iName
Field Prefix Letter Determines Action
Form Field Naming Conventions
Linking To This Secure Form
Email Verification
Luhn Algorithm for Credit Card Validation
The Order is Time Stamped
Program Options
Different Modes of Operation
Can Now Operate In Window 7/2002
Thank You Message is Definable 10/2000
Form Type is Definable 10/2000
Show Reference Number is Definable 10/2000
Inquiry Only Mode (3) 4/2000
Secure Without Client Verification, Mode (5) 4/2000
Store Customer Names in Server Side Database
Example of a Form Top Section With Database Tags
Explanation of Database Form Fields
Special iTimeStamp Field

Operating instructions for Dagra SORD.CGI

eCommerce Home
A Dagra Software CGI Program to connect with an HTML form for secure ordering on the Internet. SORD.CGI is written in 'C' and compiled to present an execute only interface to your HTML form for added security.

Top

The Steps For Operation:

  1. Fill in the order form that connects to "sord.cgi" being sure that all required fields are completed.
  2. Submit for Verify.
  3. Proof read your entries from the verification screen, then click the "Submit Order" button.
  4. After the order is submitted you will click a link that leaves the secure environment.

The system will then email the completed order to the specified company to be filled and shipped.

The system will also email a confirmation copy with credit card info blocked with * to the client if the aEmail or bEmail field was filled in with a valid email address, see email verification for more.

Note: The system requires that aName field be filled in correctly so that the program can use his name later (you can substitute aCardHolderName for aName if you wish). There may also be other required fields, those that are named with a leading a, c or g.

In case of an error or emission the program tells the user what is wrong and gives him an opportunity to fix it.

Top

Adapting Your HTML Form for Connecting with sord.cgi

The form begins with the "<form" tag that is followed by 3 special hidden tags and some optional hidden tag that give the program needed information. The 3 must be present for the system to operate, the optional ones are explained under options. When a Mode tag is present it should always be the first hidden tag below the form beginning, the default mode is 1.

<form name="sord" action="sord.cgi" method="post">
<input type="hidden" name="Email_to" value="dagra@lightlink.com">
<input type="hidden" name="Home_html" value="http://www.lightlink.com/dagra/">
<input type="hidden" name="Form_owner" value="Dagra Software">
Optional:
<input type="hidden" name="iThankYou" value="Thank you for your order">
<input type="hidden" name="iLeaveSecure" value="Your transaction is now complete, you will leave the secure environment.">
<input type="hidden" name="iFormType" value="Inquiry">
<input type="hidden" name="iUse_client_email" value="Y">
<input type="hidden" name="iShowRefNo" value="Y">

Note: These special tags do not use a prefix letter and are therefore discarded after use by the program.

  1. "Email_to" is the email address where orders will be sent, it must be a valid address.
  2. "Home_html" this is the link back to your home page. This must be a fully qualified link - http://etc. - is required for a clean exit from the secure environment.
  3. "Form_owner" is the name of your company as you want your client to see it. This will be used in the confirmation email that goes to the client.

In addition to these special fields there are two more that accept client input but get special handling. aName will be used to call the client by name in the thank you screen at the end of the transaction. aEmail, bEmail or eEmail will be verified as a valid email address and used to send the confirmation to the client.

Top

Optional Internal Variables iName

All iName fields are used for passing variables to the program that are used internally and not passed on in the final data. These fields are shown in this documentation file with their default values, therefore omitting then will yield the same result as is shown. The intent is to allow you to change the value of these variables easily and to be compatible with forms that were written for previous versions of sord.cgi.

Top

Field Prefix Letter Determines Action

We have chosen to use a single lower case letter as a prefix that the CGI program can trap and act upon. This plan is compliant with Java and JavaScript language specifications therefore providing us the greatest flexibility for our forms.

Each field in your form must begin with a prefix letter for the CGI program to process it. Program action is determined by this prefix as follows:
a = required field
b = not required, only fields with data are displayed for verification
c = required credit card field (will convert to *** in confirmation)
d = not required credit card field (will convert to *** in confirmation)
e = not required but will be shown in verification screen even if there is no value.
f = returned but not shown in verify or confirmation
g = required credit card number field - tested by Luhn algorithm (will convert to *** in confirmation)
i = internal optional variable used by sord.cgi in all steps but not passed in final data.

Note: You can hide field names from sord.cgi by using a capital letter as the first letter in the name. These fields will simply be ignored by the program.

Since a, c & g fields are always required you should let the client know that by marking these with an asterisk and a note to explain.

You are free to change the form any way you like with a few considerations for the CGI program and security.

  1. The required aName field name must be present. (Can be aCardHolderName.)
  2. Your form should always contain a aEmail, bEmail or eEmail field for the confirmation to work, a if you want to require it, b if not, e if you want client to see even if not filled in.
  3. The credit card field names should begin with c, d or g so the program will convert to *** in confirmation.
  4. You may add any fields that you wish, but be sure to start each with a listed prefix letter.
  5. The HTML form cannot contain nested sub-forms.

Following these simple rules you are free to incorporate graphics and animation within your form as you wish.

Top

Form Field Naming Conventions

In the section above you read about the prefix that tells the system how to handle each field, here we will consider the people who use the system. As you decide on names for the fields in your form there are some of things to remember.

  1. Each field name begins with a prefix followed by the identification for that field using upper and lower case letters as well as numbers but no spaces.
  2. The prefix that precedes each name is seen only by the CGI program, it is invisible to the client and to the final recipient.
  3. The client who fills in the form sees the prompt as he types into it. But at the verify screen he sees the field names.
  4. The final recipient sees the field name and the value that was typed in for it.

It is a good idea to keep the prompts short and to make the names resemble the prompts. You can use capitalization to make the names readable like bStreetAddress or bPOBox. Keep in mind that the field that identifies the person filling in the form must be named aName. Large variations in field name length make the verify and final email hard to read, bStAddress would be better than bStreetAddress for example.

Top

Linking To This Secure Form

The HTML form, the sord.cgi program and support files are all placed together in a folder (secure) within your account. This folder is made execute only for security. Links to this form can be made from anywhere in the following form:
https://www.lightlink.com/account/secure/sord.htm

  1. Your domain name cannot be used in this secure link, it must be an absolute link to maintain security.
  2. You are free to change the form any way you like with a few considerations for the CGI program and security.
  3. The HTML form cannot contain any links that leave the secure folder.
  4. All referenced images should be placed within this same secure directory.

With these guidelines you can present an attractive yet secure form to your clients.

Top

Email Verification

Email addresses are central to the operation of our system and present a special challenge to the CGI program. If the program attempts to send an email with an invalid or incorrect email address the user will see an error message that says something like "A server error has occurred, if this continues contact the system administrator." We do some additional verification to avoid this error as follows.

  1. aEmail is required because it has the "a" prefix, we must therefore test it.
  2. bEmail or eEmail is optional so we only verify if there is data in the field.

The validation is:

  1. If the address is less that 6 characters long it is deleted and considered empty.
  2. The address must contain both the part that precedes the @ and the part that follows it.
  3. The final section (after the @) must contain a period.

Top

Luhn Algorithm for Credit Card Validation

This test insures that the number is a well formed card number. If the test fails then the card number could not possibly be correct. However if the number passes the test there is no assurance that the card number is good, only that it could be. There is no way of knowing whether a card number actually belongs to the person that is presenting it. Usually a typing error will result in an improperly formed card number and be caught by the Luhn test.

Top

The Order is Time Stamped

The order that is conveyed to the company has a timestamp that is generated by sord.cgi when the order is submitted. This is also the exact time that the confirmation is sent to the buyer. The timestamp is mm/dd/yyyy:hh:mm as 04/29/2001:11:33 - April 29, 2001 at 11:33 AM. 1:00 PM is represented as 13:00. The form of the timestamp can easily be used by a program later in the production cycle. This can also be saved into a database field if you wish, see the database instructions.

Top

Program Options

If the server permits it we can apply the clients email address to the email that is returned to us containing the order. Should we need to correspond with the client about an order it is really convenient to be able to hit the reply button, add comments and send it off. This tag provides support for that.
Optional:
<input type="hidden" name="iUse_client_email" value="Y">
The result of "Y" here creates a situation where an email that is sent from our web page shows our client as the sender, a practice that may not be permitted by the server. Even if permitted now this could change in the future, the option allows us to change if required without compiling the program.
Note: Older versions of sord.cgi used "Use_client_email" without the i in front, that is still supported.

Top

Different Modes of Operation

The default action of sord.cgi is to accept data from an HTML form (mode 1) then return a generated form for the client to verify (mode 2). To increase the flexibility of the program we have added an inquiry mode (mode 3) that does not send a confirmation and does not need a secure connection. Mode 5 is exactly like mode 1 except the verification step is skipped. These are each described in their own section below. Only modes 1, 3 and 5 are definable.

Top

Can Now Operate In Window 7/2002

If you wish sord.cgi to be called from a form that is operating in a window you will want to change the home link to instructions for closing the window. Change the line for Home_html to the following:
<input type="hidden" name="Home_html" value="CLOSE WINDOW">
The program will end with:
Click the X at upper right corner of this window to close window
instead of the link to the home page.

Top

Thank You Message is Definable 10/2000

To increase the flexibility of SORD.CGI we have added two variables that allow the thank you message that is displayed after the final form submission to become more user definable. The default value is: Thank you for your order just as it was before the change. To set this variable to a new value add these two lines to the hidden fields at the top of the form.
<input type="hidden" name="iThankYou" value="Thank you for your order">
<input type="hidden" name="iLeaveSecure" value="Your transaction is now complete, you will leave the secure environment.">
Edit the value to your message but try to maintain the length to approximately the same as the default. The program will truncate these message lines at 79 characters each. The program adds one space and the value of the required aName or aCardHolderName to the thank you line at run time.

Top

Form Type is Definable 10/2000

Since SORD.CGI can be used for forms other than order forms we have added a variable that allows you to change the word order that is used in the confirmation and email from the default Order to Application, Inquiry, Request or any other single word that describes your application. To set this variable to a new value add this line to the hidden fields at the top of the form.
<input type="hidden" name="iFormType" value="Order">
Change Order to a word that suites your application.

Top

Show Reference Number is Definable 10/2000

When using sord.cgi to support forms that are not order forms you may not want to assign a reference number. If you set the hidden internal field as shown
<input type="hidden" name="iShowRefNo" value="N">
the entire reference number process is suppressed and the line that shows it is omitted from the confirmation email and the order.

Top

Inquiry Only Mode (3) 4/2000

You can also use sord.cgi for a form that is simply an inquiry. That is the results of the form will be sent to you without showing the client the usual data verification screen and without sending a confirmation to the client.

The hidden fields at the top of the form are joined by one additional field as shown in bold below to inform sord.cgi that it is to run in mode 3. When a Mode tag is present it should always be the first hidden tag below the form beginning. The default value for the thank you message is: Thank you for your inquiry. The default value for the form type is: Inquiry. Note the relative call to the home page that will only be used if the form is called as a non-secure page as shown below.

<form name="sord" action="sord.cgi" method="post">
<input type="hidden" name="Mode" value="3"> <input type="hidden" name="Email_to" value="dagra@lightlink.com">
<input type="hidden" name="Home_html" value="../index.html">
<input type="hidden" name="Form_owner" value="Dagra Software">
<input type="hidden" name="iUse_client_email" value="Y">
<input type="hidden" name="iThankYou" value="Thank you for your inquiry">
<input type="hidden" name="iFormType" value="Inquiry">
<input type="hidden" name="iShowRefNo" value="N">

Inquiry mode is intended to simply send an inquiry and can be used with a non-secure call. When calling the form you would use this style ./secure/inquire.html. This mode should not be used with credit card or other sensitive information. The inquiry form is still placed in the secure directory with sord.cgi to avoid path confusion. It does not tell the client that he is leaving the secure environment in the final screen.

Top

Secure Without Client Verification, Mode (5) 4/2000

If a form is particularly complex the client verification step may become so confusing that it would be better to eliminate it, mode 5 allows that. When the form is submitted it will do the data validation that is normally done in the first step then do the submission and conformation as is normally done in the second phase.

The hidden fields at the top of the form are joined by one additional field as shown in bold below to inform sord.cgi that it is to run in mode 5. When a Mode tag is present it should always be the first hidden tag below the form beginning. The default value for the thank you message is: Thank you for your order. The default value for the form type is: Order.

<form name="sord" action="sord.cgi" method="post">
<input type="hidden" name="Mode" value="5"> <input type="hidden" name="Email_to" value="dagra@lightlink.com">
<input type="hidden" name="Home_html" value="http://www.lightlink.com/dagra/">
<input type="hidden" name="Form_owner" value="Dagra Software">
Optional:
<input type="hidden" name="iThankYou" value="Thank you for your order">
<input type="hidden" name="iLeaveSecure" value="Your transaction is now complete, you will leave the secure environment.">
<input type="hidden" name="iFormType" value="Order">
<input type="hidden" name="iUse_client_email" value="Y">
<input type="hidden" name="iShowRefNo" value="Y">

Mode 5 works exactly like the default (mode 1) except that it bypasses the client verification. It does tell the client that he is leaving the secure environment in the final screen.

Top

Store Customer Names in Server Side Database

Optionally you can establish a flat file database on the server to accumulate a customer list from the clients that use a form. This feature requires a pair of files, one .txt and one .lck, with world write privileges. There will be a set for each form that is to store records. The files can be in the same directory as sord.cgi or in a directory that can be accessed with a relative link from it. For example if the database files are to be placed in ./secure/data and named cust1 then you would have ./secure/data/cust1.txt and ./secure/data/cust1.lck.

The .lck file is simply a lock file that sord.cgi uses to prevent a data collision should more than one person be submitting the same form on your Website at the same time. The lock file contains one line, STATUS=OPEN and is used exclusively by sord.cgi. Once permissions are set to 666 you should never need to touch a lock file again.

Note: Should the database function fail it will fail silently. Almost always failures occur because of a missing file, incorrect name or wrong permission setting. The program will continue to collect orders.

Top

Example of a Form Top Section With Database Tags

<form name="sord" action="sord.cgi" method="post">
<input type="hidden" name="Email_to" value="dagra@lightlink.com">
<input type="hidden" name="Home_html" value="http://www.lightlink.com/dagra/">
<input type="hidden" name="Form_owner" value="Dagra Software">
<input type="hidden" name="iThankYou" value="Thank you for your order">
<input type="hidden" name="iLeaveSecure" value="Your transaction is now complete, you will leave the secure environment.">
<input type="hidden" name="iFormType" value="Order">
<input type="hidden" name="iUse_client_email" value="Y">
<input type="hidden" name="iShowRefNo" value="Y">
Database related fields
<input type="hidden" name="iDatabaseName" value="./data/cust1.txt">
<input type="hidden" name="iDB01" value="aName">
<input type="hidden" name="iDB02" value="bEmail">
<input type="hidden" name="iDB03" value="bAddress">
<input type="hidden" name="iDB04" value="bCity">
<input type="hidden" name="iDB05" value="bState">
<input type="hidden" name="iDB06" value="bZip">

Top

Explanation of Database Form Fields

This example illustrates the setup for a form connected to cust1.txt. It is a typical name and address list as you can see by the field names. The field name that identifies the database file is always named iDatabaseName and is also the flag that triggers the process. All field names are case sensitive and the name side of the database fields all begin with iDB followed by a 2 digit number. The fields are sequentially numbered beginning with 01, there can not be missing field numbers. The value side of a database field must be an exact match for a field in the form that will collect data from your clients.

The program will write a record containing the field names with the precedent character removed whenever the database file is empty. This first record will help when you import the record into your desktop database (such as Microsoft Access) as the fields will be created with the proper names. If you change the order of fields in Access it will use the names to put the data into the correct fields. Following is some data that resulted from the setup above. You will notice that each record has a field named END at the end, this will increase your confidence in the integrity of the data. Notice also that the second record has empty fields, these will do no harm and the file will import cleanly into Access. Fields are separated by the vertical bar character, this will not conflict with data and makes for a simple import procedure.

Name|Email|Address|City|State|Zip|END
Kim Davis|kim@dagra.com|113 Emmons Rd|Lansing|NY|14882|END
Sam Smith|sam@dagra.com|||||END

To retrieve data from the server you should FTP the cust1.txt file to your computer, check it and quickly FTP an empty copy back to the server. The empty copy will overwrite the one on the server leaving it empty. Note: Do not delete the file on the server or you will need to set the permissions when you create it again. The program will write the field name record whenever the file is empty. You will then simply import the text file into Access or another desktop database.

Notes: Credit card numbers should not be saved into the database as it would be a security risk to accumulate them on the server. The maximum record length is 1000 characters and the maximum number of fields is 99. If you are anywhere close to these limits you will almost certainly have trouble handling and importing the resulting data.

Top

Special iTimeStamp Field

If you want to save a timestamp into each database record there is a special field that is generated internally just for that purpose, by calling iTimeStamp as shown in this example.
<input type="hidden" name="iDB07" value="iTimeStamp">
This is not a real field but the call is trapped within the program and the date and time written to the field.

Top
eCommerce Home
Rev. 7/2002