Verifying Form InformationIntroductionValidating form information saves you time in processing a form requested. If you require specific information or information in a specifc format, use the mgiValidateData tag to check the for the existence of the data or the format of the data and return an error message or redirect visitors to a separate error page when data is invalid. In this example, a doctor's office is accepting online registrations and validates specific data including required fields, email addresses, and appointment dates. MGI TagsSteps
Step 1: Create a medical registration form.
<FORM ACTION="register.mgi" METHOD="POST"> <H2><CENTER>Medical Appointment Registration</CENTER></H2> <P>Please complete all information as adequately as possible. This will save you time during your initial visit to our clinic. Required fields are marked in <B>bold</B>.</P> <P><CENTER><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="3" WIDTH="500"> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Patient Information</FONT></B></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Name: </FONT></B></TD> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Address, City, State, Zip Code:</FONT></B></TD> </TR> <TR> <TD WIDTH="50%" VALIGN="TOP"><INPUT NAME="Patient Name" TYPE="text" SIZE="30"></TD> <TD WIDTH="50%" VALIGN="TOP"><INPUT NAME="Patient Address" TYPE="text" SIZE="30"><BR> <INPUT NAME="Patient City" TYPE="text" SIZE="15"> <INPUT NAME="Patient State" TYPE="text" SIZE="2"> <INPUT NAME="Patient Zip" TYPE="text" SIZE="5"></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Phone Number:</FONT></B></TD> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Email Address:</FONT></B></TD> </TR> <TR> <TD WIDTH="50%"><INPUT NAME="Patient Phone" TYPE="text" SIZE="30"></TD> <TD WIDTH="50%"><INPUT NAME="Patient Email" TYPE="text" SIZE="30"></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Medical History</FONT></B></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Please list all current medications and dosages:</FONT></B></TD> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Please describe any previous medical conditions including operations: </FONT></B></TD> </TR> <TR> <TD WIDTH="50%"><TEXTAREA NAME="Medications" ROWS="5" COLS="27"></TEXTAREA></TD> <TD WIDTH="50%"> <TEXTAREA NAME="Medical Conditions" ROWS="5" COLS="27"></TEXTAREA></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Insurance Information</FONT></B></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Insurance Provider:</FONT></B></TD> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Group Number:</FONT></B></TD> </TR> <TR> <TD WIDTH="50%"><INPUT NAME="Insurance Provider" TYPE="text" SIZE="30"></TD> <TD WIDTH="50%"><INPUT NAME="Group Number" TYPE="text" SIZE="30"></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><FONT SIZE="-1">Claims Telephone Number:</FONT></TD> <TD WIDTH="50%"> </TD> </TR> <TR> <TD WIDTH="50%"><INPUT NAME="Claims Phone" TYPE="text" SIZE="30"></TD> <TD WIDTH="50%"> </TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Emergency Contact Information</FONT></B></TD> </TR> <TR> <TD WIDTH="50%" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Name:</FONT> </B></TD> <TD WIDTH="50%" BGCOLOR="#eeeeee"><FONT SIZE="-1">Address, City, State, Zip Code:</FONT></TD> </TR> <TR> <TD VALIGN="TOP"><INPUT NAME="Contact Name" TYPE="text" SIZE="30"></TD> <TD VALIGN="TOP"><INPUT NAME="Contact Address" TYPE="text" SIZE="30"><BR> <INPUT NAME="Contact City" TYPE="text" SIZE="15"> <INPUT NAME="Contact State" TYPE="text" SIZE="2"> <INPUT NAME="Contact Zip" TYPE="text" SIZE="5"></TD> </TR> <TR> <TD BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Phone Number: </FONT></B></TD> <TD BGCOLOR="#eeeeee"><FONT SIZE="-1">Alternate Phone Number:</FONT></TD> </TR> <TR> <TD><INPUT NAME="Contact Phone" TYPE="text" SIZE="30"></TD> <TD><INPUT NAME="Contact Alt Phone" TYPE="text" SIZE="30"></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Reason for Visit</FONT></B></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#eeeeee"><FONT SIZE="-1">Please describe the reason for your current visit to our clinic:</FONT></TD> </TR> <TR> <TD COLSPAN="2"> <TEXTAREA NAME="Reason for Visit" ROWS="5" COLS="60"> </TEXTAREA></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#66cccc"><B><FONT SIZE="+1">Appointment Date</FONT></B></TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#eeeeee"><B><FONT SIZE="-1">Select your preferred appointment date. The date you choose cannot be more than 30 days after the current date (<mgiDate>).</FONT></B></TD> </TR> <TR> <TD COLSPAN="2"> <P><CENTER><SELECT NAME="Month"> <OPTION SELECTED VALUE="">Month <OPTION VALUE="01">January <OPTION VALUE="02">February <OPTION VALUE="03">March <OPTION VALUE="04">April <OPTION VALUE="05">May <OPTION VALUE="06">June <OPTION VALUE="07">July <OPTION VALUE="08">August <OPTION VALUE="09">September <OPTION VALUE="10">October <OPTION VALUE="11">November <OPTION VALUE="12">December </SELECT> <SELECT NAME="Day"> <OPTION SELECTED VALUE="">Day <OPTION>01 <OPTION>02 <OPTION>03 <OPTION>04 <OPTION>05 <OPTION>06 <OPTION>07 <OPTION>08 <OPTION>09 <OPTION>10 <OPTION>11 <OPTION>12 <OPTION>13 <OPTION>14 <OPTION>15 <OPTION>16 <OPTION>17 <OPTION>18 <OPTION>19 <OPTION>20 <OPTION>21 <OPTION>22 <OPTION>23 <OPTION>24 <OPTION>25 <OPTION>26 <OPTION>27 <OPTION>28 <OPTION>29 <OPTION>30 <OPTION>31 </SELECT> <SELECT NAME="Year"> <OPTION SELECTED VALUE="">Year <OPTION>2001 <OPTION>2002 </SELECT></CENTER></TD> </TR> </TABLE></CENTER></P> <P><CENTER><input type="submit" value="Submit Registration"></CENTER> Step 2: Create a registration processing page and open it in a text editor.
Step 3: Validate the form information and send a formatted email.
<H2><CENTER>Medical Appointment Submission</CENTER></H2> <mgiSet name="FormattedDate"> <mgiPostArgument name="Month">-<mgiPostArgument name="Day">- <mgiPostArgument name="Year"> </mgiSet> <mgiSet name="Validation"> Patient Information ------------------- Name: <mgiValidateData data={mgiPostArgument name="Patient Name"}> Address: <mgiValidateData data={mgiPostArgument name="Patient Address"}> <mgiValidateData data={mgiPostArgument name="Patient City"}> <mgiValidateData data={mgiPostArgument name="Patient State"}> <mgiValidateData data={mgiPostArgument name="Patient Zip"}> Phone: <mgiValidateData data={mgiPostArgument name="Patient Phone"}> Email: <mgiValidateData data={mgiPostArgument name="Patient Email"} format="emailAddress"> Medical History --------------- Medications: <mgiValidateData data={mgiPostArgument name="Medications"}> Conditions: <mgiValidateData data={mgiPostArgument name="Medical Conditions"}> Insurance Information --------------------- Provider: <mgiValidateData data={mgiPostArgument name="Insurance Provider"}> Group: <mgiValidateData data={mgiPostArgument name="Group Number"}> Claims: <mgiPostArgument name="Claims Phone"> Emergency Contact ----------------- Name: <mgiValidateData data={mgiPostArgument name="Contact Name"}> Address: <mgiPostArgument name="Contact Address"> <mgiPostArgument name="Contact City"> <mgiPostArgument name="Contact State"> <mgiPostArgument name="Contact Zip"> Phone: <mgiValidateData data={mgiPostArgument name="Contact Phone"}> Alt Phone: <mgiPostArgument name="Contact Alt Phone"> Reason for Visit ---------------- <mgiPostArgument name="Reason for Visit"> Requested Appointment Date: <mgiValidateData type="date" data={mgiGet name="FormattedDate"} upperSpan="30"> </mgiSet> <mgiIf lhs={mgiGet name="Validation"} relationship="contains" rhs="invalid data"> <p><b>An error has occurred processing your appointment request.</b> Please use the "Back" button on your browser and verify the information you have entered. Make sure all required fields have been completed, all email addresses are formatted properly and that your selected appointment date is not more than 30 days from today's date. <mgiElse> <P>Your registration and appointment information has been received. Please bring copies of any previous medical records during your visit. Your appointment time will be verified by phone. <mgiSendMail to="registration@domain.com" from={mgiPostArgument name="Patient Email"} subject="Medical Registration" mailserver="mail.domain.com"> <mgiGet name="Validation"> </mgiSendMail> </mgiIf> Step 4: Save the registration processing page.
Step 5: FTP the registration form and processing page to the web server running MGI.
Step 6: View the registration form in a web browser and request an appointment.
Patient Information ------------------- Name: Charles Washington Address: 123 Main Ave Durham NC 21546 Phone: 123-456-7894 Email: charles@dbulls.net Medical History --------------- Medications: Allegra - 50 MG Conditions: Allergies Diabetes Insurance Information --------------------- Provider: Blue Cross/Blue Shield Group: F8993H232121 Claims: 704-256-8945 Emergency Contact ----------------- Name: Helen Washington Address: 123 Main Ave Durham NC 21546 Phone: 123-456-7894 Alt Phone: 856-456-7845 Reason for Visit ---------------- Yearly physical and checkup. Requested Appointment Date: 06-03-2001 |