Processing Forms to Email

Introduction

Forms allow your web site visitors to interact with you. To receive the visitor's information, use the mgiSendMail tag to translate the form submission into a formatted email.

In this example, a store is collecting comments about their products.

MGI Tags

Steps

  1. Create an information request form.
  2. Create a form processing page and open it in a text editor.
  3. Insert the mgiSendMail tag.
  4. Save the form processing page.
  5. FTP the information request form and form processing page to the web server running MGI.
  6. View the information request form in a web browser and submit the request.


Step 1: Create an information request form.

Create an information request form with form elements. In this example, the information request form consists of text fields for the visitor's Name, Company, Address, City, State, Zip, Country, Phone Number, and Email Address, and a text box for Comments. Name each form element uniquely. Enclose all form elements with HTML <FORM> tags and post the form to the form processing page (infoprocess.mgi).
 
This is an example information request form.
<form action="infoprocess.mgi" method="post">

<h2>Information Request Form</h2>

<P><CENTER>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR><TD ALIGN="RIGHT">Name</TD> 
<TD><INPUT NAME="Name" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Company</TD> 
<TD><INPUT NAME="Company" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Address</TD> 
<TD><INPUT NAME="Address" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">City</TD> 
<TD><INPUT NAME="City" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">State</TD> 
<TD><INPUT NAME="State" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Zip</TD> 
<TD><INPUT NAME="Zip" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Country</TD> 
<TD><INPUT NAME="Country" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Phone Number</TD> 
<TD><INPUT NAME="Phone" TYPE="text" SIZE="40"></TD>
</TR> 
<TR><TD ALIGN="RIGHT">Email Address</TD> 
<TD><INPUT NAME="Email" TYPE="text" SIZE="40"></TD>
</TR></TABLE>

</CENTER></P>

<P><CENTER>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR><TD><CENTER><P>Please describe any specific 
comments or questions in the box below.</P>
<P><TEXTAREA NAME="Comments" ROWS="7" COLS="50">
</TEXTAREA></P>
<P><INPUT TYPE="submit" VALUE="Submit Request">
</P></CENTER>
</TD></TR>
</TABLE>

</CENTER></P>

</form>

Step 2: Create a form processing page and open it in a text editor.

Create a page named "infoprocess.mgi" to format the form information and send it to the designated address via email. Open the page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 3: Insert the mgiSendMail tag.

Enter the beginning mgiSendMail tag, to parameter, from parameter, mailServer parameter, subject parameter, and ending mgiSendMail tag. In the "to" parameter enter the recipient's email address. In the "from" parameter, enter the sender's email address. In the "mailServer" parameter, enter the address of the outgoing SMTP server. In the "subject" parameter, enter the subject of the email.
 
In the body of the mgiSendMail tags, enter text labels and an mgiPostArgument tag for each form element. In the name parameter of mgiPostArgument, enter the name of the form element to display.
 
This is an example form processing page.
<h2><center>Information Request Submission
</center></h2>

<p><center>Thank you for your request.  
A representative will contact you shortly.
</center></p>

<mgiSendMail to="info@domain.com" 
from="webmaster@domain.com" 
mailserver="mail.domain.com" 
subject="Info Request">
Information Request
*******************

   Name: <mgiPostArgument name="name">
Company: <mgiPostArgument name="company">
Address: <mgiPostArgument name="address">
   City: <mgiPostArgument name="city">
  State: <mgiPostArgument name="state">
    Zip: <mgiPostArgument name="zip">
Country: <mgiPostArgument name="country">
  Phone: <mgiPostArgument name="phone">
  Email: <mgiPostArgument name="email">

Comments:
<mgiPostArgument name="comments">
</mgiSendMail>

Step 4: Save the form processing page.

Save the changes you have made to the form processing page.

Step 5: FTP the information request form and form processing page to the web server running MGI.

Upload the information request form and form processing page from your local computer to the web server using an FTP program.

Step 6: View the information request form in a web browser and submit the request.

View the information request form in a web browser. Complete and submit the information request form. An email with the following format is sent to the specified recipient
Information Request
*******************

    Name: Allan Para
 Company: Para, Inc.
 Address: 1234 Main Ave.
    City: Denver
   State: CO
     Zip: 33489
 Country: US
   Phone: 848-293-4712
   Email: allan@parainc.com

Comments:
I am interested in your product, but does it 
come in different sizes?


[Return to the Forms Submission Menu]


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]