Setting and Displaying Page Variables

Introduction

Variables are containers for information such as text, HTML and MGI tags. Variables allow you to "hold" information until you need to display it further down the page or on another page of the site. The information in page variables is available from the point at which they are set until they are overwriiten or until the end of the page that is currently processing, whichever occurs first. The information in site variables is stored in a database and is available from the point at which they are set until they are overwritten by a new value or deleted.

More often than not, the value of a variable is embedded in the parameter of another MGI tag. Read more about embedding.

In this example, a page variable is used to concatenate and hold the subject of a confirmation email from a customer's form submission. The subject is then embedded in the confirmation mgiSendMail tag.

MGI Tags

Steps

  1. Create an information request form.
  2. Create a send mail page for the information request and open it in a text editor.
  3. Insert the mgiSet tag, mgiPostArgument tag, and mgiSendMail tags.
  4. Save the send mail page.
  5. FTP the information request form and send mail page to a web server running MGI.
  6. View the form in a web broswer and complete the information request.


Step 1: Create an information request form.

Create an information request page named "inforequest.mgi" with form elements. In this example, the information request form consists of form fields for name, address, phone, email and comments. Name each form element uniquely. Enclose all form elements with HTML <FORM> tags and post the form to the send mail page (infoprocess.mgi).
 
This is an example information request form.
<FORM action="infoprocess.mgi" method="post">

<H2><CENTER>Information Request</CENTER></H2>

<P><CENTER>
Please complete all information below.
</CENTER></P>

<H2><CENTER>
<TABLE BORDER="1" CELLSPACING="1" CELLPADDING="3">
  <TR>
    <TD ALIGN="RIGHT">Name:</TD>
    <TD>&nbsp;
<INPUT NAME="Name" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Address:</TD>
    <TD>&nbsp;
<INPUT NAME="Address" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Phone:</TD>
    <TD>&nbsp;
<INPUT NAME="Phone" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Email:</TD>
    <TD>&nbsp;
<INPUT NAME="Email" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Questions/Comments:</TD>
    <TD>&nbsp;
<TEXTAREA NAME="Comments" ROWS="7" COLS="27">
</TEXTAREA></TD>
  </TR>
  <TR>
    <TD>&nbsp;</TD>
    <TD><P><CENTER>
    <INPUT TYPE="submit" VALUE="Submit Request">
    </CENTER></TD>
  </TR>
</TABLE>
</CENTER></H2>

</FORM>

Step 2: Create a send mail page for the information request and open it in a text editor.

Create a page named "infoprocess.mgi" to process the information request and send a confirmation email to the visitor. Open the send mail page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 3: Insert the mgiSet tag, mgiPostArgument tag, and mgiSendMail tags.

To create the subject of the confirmation email, enter a beginning mgiSet tag, name parameter and ending mgiSet tag. In the name parameter, enter the name of the page variable "ConfirmationSubject". In the body of the mgiSet tags, construct the email subject by dynamically entering the customer's name from the information request form using an mgiPostArgument tag.
 
To send a confirmation email, enter the mgiSendMail tag. Embed the variable value in the subject of the mgiSendMail tag using the mgiGet tag and name parameter. In the name parameter, enter the name of the page variable to display "ConfirmationSubject". To process the information request, enter a second mgiSendMail tag.
 
This is an example send mail page.
<H2><CENTER>Information Request Submission</CENTER></H2>

<P><CENTER>Thank you, your information 
request has been sent.</CENTER></P>

<mgiSet name="ConfirmationSubject">
<mgiPostArgument name="Name"> Receipt Confirmation
</mgiSet>

<mgiSendMail to={mgiPostArgument name="Email"} 
from="info@domain.com" mailserver="mail.domain.com" 
subject={mgiGet name="ConfirmationSubject"}>
Thank you <mgiPostArgument name="Name">.
We have received your request for additional 
information. A representative will respond by 
phone or email within 48 hours. 
Please visit our site again.
</mgiSendMail>

<mgiSendMail to="info@domain.com" 
from="info@domain.com" mailserver="mail.domain.com" 
subject="Info Request">
Information Request
*******************
    Name: <mgiPostArgument name="Name">
 Address: <mgiPostArgument name="Address">
   Phone: <mgiPostArgument name="Phone">
   Email: <mgiPostArgument name="Email">
Comments: <mgiPostArgument name="Comments">
</mgiSendMail>

Step 4: Save the send mail page.

Save the changes you have made to the send mail page.

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

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

Step 6: View the form in a web broswer and complete the information request.

View the information request form in a web browser and complete all fields of the form. When you submit the form, a confirmation email is sent to the customer and the information request is sent to the company.
 
This is an example confirmation email. The subject of this email is "Andrew Carey Receipt Confirmation".
Thank you Valerie Crisp.
We have received your request for additional 
information. A representative will respond by 
phone or email within 48 hours. 
Please visit our site again.
This is an example information request email.
Information Request
*******************
    Name: Andrew Carey
 Address: 125 Main St New York NY 20001
   Phone: 256-458-9654
   Email: acarey@aol.com
Comments: I am interested in product 233445. What 
sizes are in stock?


[Return to the Variables Menu]


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


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