Email Form Script How-To

advertisement
Email Form Script How-To
The Library Systems Office has created a generic email form script that can be used
on any form within the library.uiuc.edu system. Guidelines for how to create your form
to use this page are included below. In general, you need:
1. Have a properly formatted form
2. Have a success page
3. Have a failure page
Have a properly formatted form
Create Your Form
Using a web editor of your choice, such as FrontPage, create your form fields
(text boxes, checkboxes, radio buttons, ect.). As you create each form field write down
the name of the fields and the order you wish to have them sent to you in an email. To
find the name of a given field go to the html view and look for a line similar to:
<INPUT TYPE=”TEXT” NAME=”fieldname” SIZE=”35”>
The name of this form field would be fieldname. Look through the entire html and find
the name for each of your form fields.
Set Form Action
The form method and action now need to be set. Again, go into your html view
and look for a line that starts off with <FORM. In Frontpage the default is often:
<form method="POST" action="--WEBBOT-SELF--">
Change the HTML to post to /cgis/emailform.cgi by replacing the current <FORM line
with:
<FORM METHOD="POST" ACTION="/cgis/emailform.cgi">
Create Hidden Fields
The data_order field should contain all fields that you want displayed in the email
sent to you and the order they should be displayed in. You should have written down all
of the fields when you originally created your form. Any fields not placed in this list will
not be in the email. In html view place this line right before your submit button, with
field1,field2,field3 replaced with the field names collected earlier.
<INPUT TYPE="HIDDEN" NAME="data_order" VALUE="field1,field2,field3">
The submit_to field is a comma separated list of addresses you want the email
sent to. These must be in the uiuc.edu domain. Place this between the submit button and
the above line with the email address changed to yours.
<INPUT TYPE="HIDDEN" NAME="submit_to" VALUE="blah@uiuc.edu,blah1@uiuc.edu">
The ok_url field is the full address of the page that will be displayed to the user
after the form is submitted successfully. It should tell them the information was sent
successfully and have a link back to your page. Place this between the submit button and
the above line with the web address changed to yours.
<INPUT TYPE="HIDDEN" NAME="ok_url" VALUE="http://www.library.uiuc.edu/test/thanks.html">
Sample Form
<HTML>
<BODY BGCOLOR="#CCCCCC">
<CENTER>
<B>Sample<BR>
</CENTER>
<P>
<FORM METHOD="POST" ACTION="/cgis/emailform.cgi">
<PRE>
Your Name:
<INPUT TYPE="TEXT" NAME="name" SIZE=35 MAXLENGTH=50>
Country:
<INPUT TYPE="TEXT" NAME="country" SIZE=35 MAXLENGTH=50>
E-Mail Address:
<INPUT TYPE="TEXT" NAME="submit_by" SIZE=35 MAXLENGTH=50>
How did you find us:
<INPUT TYPE="TEXT" NAME="how_found" SIZE=35 MAXLENGTH=50>
<INPUT TYPE="SUBMIT">
</PRE>
<!-- SCRIPT CONFIGURATION SECTION -->
<INPUT TYPE="HIDDEN" NAME="data_order"
VALUE="name,country,submit_by,how_found">
<INPUT TYPE="HIDDEN" NAME="submit_to" VALUE="blah@uiuc.edu,blah1@uiuc.edu">
<INPUT TYPE="HIDDEN" NAME="ok_url" VALUE="http://www.library.uiuc.edu/test/thanks.html">
<!-- END OF SCRIPT CONFIGURATION SECTION -->
</FORM>
</BODY>
</HTML>
Download