From Support Center
How do I set up a formmail or comment form on my website?
- First you will need to download our formmail kit. Click here to download the .ZIP File (http://support.globat.com/formmail/formmail.zip).
- There are two files required to send email from a form on your website.
-
File 1 "index.html" is the HTML frontend.
- This is what visitors to your site will see. It can be modified to match the look and feel of your website in any HTML editor or Microsoft FrontPage.
- It is highly recommended that you change the name of this file to another filename of your choice. Suggested file names are comments.html or feedback.html.
- Caution: If you upload it to your web space as index.html without renaming it, it will overwrite your current index file!
-
File 2 "formmail.php" is the PHP backend script.
- This code is invisible to the customer. It takes input from the HTML frontend and emails it to you. This file is called formmail.php
Basic Setup
- Open "formmail.php" with a text editor
-
- Find the line highlighted above (see picture) in your copy of formmail.php.
- Change www.yoursite.com and yoursite.com to have the name of your domain name. (Example : www.bob.com)
- Open "index.html" with a text editor or HTML editor like Macromedia Dreamweaver, Adobe Golive, or Microsoft FrontPage.
- You must set the address that the form will be emailed to inside of the HTML tags with this code. This tag is required for the formmail to function:
<INPUT type=hidden name="recipient"
value="your_email@your_site.com">
- You will see a line above that line in the HTML file, that looks like this:
<form name="form1" method="post" action="formmail.php">
- To have the confirmation screen for the customer open into a new web browser window (recommended) add target="_blank" as shown below:
<form name="form1" method="post" action="formmail.php" target="_blank">
- If instead, you wish to place a link for the visitor to return to your site, set these:
<INPUT type="hidden" value="http://your.host.com/main.html"
name="return_link_url">
<INPUT type="hidden" value="title here"
name="return_link_title">
- ...by adding those two lines, modified to your needs, before the </form>.
You're finished! Upload your -renamed- HTML file and PHP script to your website, within httpdocs or a subfolder of httpdocs.
Optional Form Fields
Field: subject
- Description: The subject field will allow you to specify the subject that you wish to appear in the e-mail that is sent to you after this form has been filled out. If you do not have this option turned on, then the script will default to a message subject: WWW Form Submission
- Syntax: If you wish to choose what the subject is:
<INPUT type="hidden" value="Your Subject"
name="subject">
- To allow the user to choose a subject:
<INPUT name="subject">
Field: email
- Description: This form field will allow the user to specify their return e-mail address. If you want to be able to return e-mail to your user, I strongly suggest that you include this form field and allow them to fill it in. This will be put into the From: field of the message you receive. If you want to require an email address with valid syntax, add this field name to the 'required' field.
To send e-mail to more than one address, use commas to seperate the addresses.
- Syntax: Single Recipient:
<INPUT value="nobody@example.com" name="email">
- Multiple Recipients:
<INPUT value="nobody@example.com,nobody@example1.com"
name="email">
Field: recipient_cc*
- Description: This form field will allow you to carbon copy (CC) the the e-mail to the e-mail address listed. Use this only if you have the email field specified. This will cause two copies of the e-mail to be sent. The first to the address listed in the email field and the second to the address listed in the recipient_cc.
- To send e-mail to more than one address, use commas to seperate the addresses.
- Syntax: Single Recipient:
<INPUT value="nobody@example.com" name="recipient_cc">
- Multiple Recipients:
<INPUT value="nobody@example.com,nobody@example1.com"
name="recipient_cc">
Field: recipient_bcc*
- Description: This form field will allow you to blind carbon copy (BCC) the the e-mail to the e-mail address listed. To use this fields, you don't have to specify the email field. This will cause the e-mail to be sent but the recipients listed in the recipient_bcc without the recipients to see who it was sent to.
- To send e-mail to more than one address, use commas to seperate the addresses.
- Syntax: Single Recipient:
<INPUT value="nobody@example.com" name="recipient_bcc">
- Multiple Recipients:
<INPUT value="nobody@example.com,nobody@example1.com"
name="recipient_bcc">
Field: realname
- Description: The realname form field will allow the user to input their real name. This field is useful for identification purposes and will also be put into the From: line of your message header.
- Note: If realname does not exist as a field but firstname or lastname does, PHPFormMail will combine firstname and lastname to create the realname.
- Syntax:
<INPUT name="realname">
Field: redirect
- Description: If you wish to redirect the user to a different URL, rather than having them see the default response to the fill-out form, you can use this hidden variable to send them to a pre-made HTML page.
- Syntax:
<INPUT type="hidden" value="http://your.host.com/to/file.html"
name="redirect">
Field: redirect_values
- Description: This send the form results on to the redirect page (for further processing by your own script). You must specify redirect and/or missing_fields_redirect for this feature to work. NOTE: You must use the GET method for this feature to work.
- Syntax:
<INPUT type="hidden" value="true"
name="redirect_values">
Field: required
- Description: You can now require for certain fields in your form to be filled in before the user can successfully submit the form. Simply place all field names that you want to be mandatory into this field. If the required fields are not filled in, the user will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.
- To use a customized error page, see 'missing_fields_redirect'
- Syntax: If you want to require that they fill in the email and phone fields in your form, so that you can reach them once you have received the mail, use a syntax like:
<INPUT type="hidden" value="email,phone"
name="required">
Field: sort
"'Description: There are three ways to sort the output of the form.
- Alphabetic *: An alphabetic listing based on the field names.
- Reverse Alphabetic *: A reverse alphabetic listing based on the field names.
- Order: Allows you to specify the order that you would like the fields to be in. Note: If you have five form variables, and you only wish to move two of them to the begining of the e-mail and allow the others to stay in their natural order, you just need to specify the two variables. The remaining variables will be included in the e-mail.
- For Alphabetic listings*:
<INPUT type="hidden" value="alphabetic"
name=sort>
- For Reverse Alphabetic listings*:
<INPUT type="hidden" value="ralphabetic"
name="sort">
- For Order listings (This would list the fields in the order of: name, comment, email):
<INPUT type="hidden" value="order:name,comment,email"
name="sort">
Field: hidden*
- Description: Allows you to hide the results of a field from the HTML output. The results will be replaced with (hidden) in the HTML output but will still appear in the e-mail you receive. Fields are comma separated.
- Syntax: If you want to hide the results of the fields my_password and home_address, you would use syntax like:
<INPUT type="hidden" value="my_password,home_address"
name="hidden">
Field: alias*
- Description: Allows you to add a more user friendly name for the field. This user friendly name is only displayed in the HTML output and as no effect on the e-mail you receive. Format is fieldname="friendlyname" and is comma separated.
- Syntax: To add the alias of "E-mail Address" to the field of "email" and the alias of "First Name" to the field of firstname use:
<INPUT type="hidden" value="email=E-mail Address,firstname=First Name"
name="alias">
Field: env_report
- Description: Allows you to have Environment variables included in the e-mail message you receive after a user has filled out your form. Useful if you wish to know what browser they were using, what domain they were coming from or any other attributes associated with environment variables. Each enviroment variable is sepperated by a comma. The following is a short list of valid environment variables that might be useful:
REMOTE_HOST - Sends the hostname making the request.
REMOTE_ADDR - Sends the IP address of the remote host
making the request.
REMOTE_USER - If server supports authentication and
script is protected, this is the username
they have authenticated as.
*This is not usually set.*
HTTP_USER_AGENT - The browser the client is using to send the request.
- For more environmental variables, please see http://hoohoo.ncsa.uiuc.edu/cgi/env.html
- Remember to allow the enviromental variables in $valid_env.
- Syntax: If you wanted to see the host making the request and the browser the user is using in your our e-mail , you would put the following into your form:
<INPUT type="hidden" value="REMOTE_HOST,HTTP_USER_AGENT"
name="env_report">
Field: priority*
- Description: priority allows you to modify the priority of the e-mail you will receive. 3 is normal priority for an e-mail (default) and 1 is the highest priority.
- Syntax: If you wish to have the highest priority:
<INPUT type="hidden" value="1"
name="priority">
- If you wish to have the lowest priority (normal):
<INPUT type="hidden" value="3"
name="priority">
Field: print_blank_fields
- Description: print_blank_fields allows you to request that all form fields are printed in the return HTML and e-mail, regardless of whether or not they were filled in. PHPFormMail defaults to turning this off, so that unused form fields aren't e-mailed.
- Syntax: If you want to print all blank fields:
<INPUT type="hidden" value="true"
name="print_blank_fields">
Field: title
- Description: This form field allows you to specify the title and header that will appear on the resulting page if you do not specify a redirect URL.
- Syntax: If you wanted a title of 'Feedback Form Results':
<INPUT type="hidden" value="Feedback Form Results"
name="title">
Field: return_link_url
- Description: This field allows you to specify a URL that will appear, as return_link_title, on the following report page. This field will not be used if you have the redirect field set, but it is useful if you allow the user to receive the report on the following page, but want to offer them a way to get back to your main page.
- Syntax:
<INPUT type="hidden" value="http://your.host.com/main.html"
name="return_link_url">
Field: return_link_title
- Description: Title shown for the return_link_url.
- Syntax:
<INPUT type="hidden" value="title here"
name="return_link_title">