White Wave Designs

Create a Readable Email Contact Form with PHP Tutorial - no Programming Skills Required

Printer-friendly version

Page Three

If you want to put an extra line between pieces of data in your email, include the following hidden field immediately preceding the field you want to space to occur in front of. For example, on my sample emailed form, I wanted a blank line between the question about how my site was found and questions about pets.

To get that blank line in the email, create a hidden form field and insert it right above the form field you want the blank space entered in front of.

<input type="hidden" name="separator1" value="separator1">
<input name="First Pet's Name" type="text" size="30">

For this to work, you MUST give the hidden form field the same name and value of "separator" plus a number. The number is keep each separator form field's name unique.

Add your submit button and close the form.

<input type="submit" name="Submit" value="Submit">

NOTE: the use of "separator" in forms is unique to my processemailform.php! It will not work with other processing files or formmail.

Now, you do not have to know php to use my function file, but there are few things you have to insert in that file. First, download the file processemailform.php (zip). Click here to view the code.

Open the file. In the "define" fields at the top of the file, replace my values in the second set of quotes with yours. Do NOT remove the double quotes!

//PSEUDO CAPTCHA: enter the answer to your "pseudo-captcha" question

//SPAM PREVENTION: enter 1 if you want to prevent users from entering 'http://' in any form field
define("PREVENT_HTTP", "1");

//REQUIRED FIELDS: enter required fields, delimited by a comma, or leave blank for none
define("REQUIRED_FIELDS_COMMA_DELIMITED", "Name, Phone, Email");

//enter 1 if you prefer html email; enter 0 if you prefer text email
define("HTML_EMAIL", "1");

//enter 1 if you are using a reset button on your form; enter 0 if you are not
define("USING_RESET_BUTTON", "0");

//put the "from" email address here; many servers require that this domain be the website domain
//if your host permits it, and you want the "from" to be the sender, require "Email" and enter $_POST['Email'] here
define("FROM", "info@website.com");

//put the receipient(s) email address here; separate multiple emails with a comma
define("SEND_TO_EMAIL", "receipient@website.com,another_person@website.com");

//enter 1 if person submitting should receive copy; enter 0 if not
define("CC_EMAIL", "1");

//put the website name here
define("WEBSITE", "Website");

//change subject line to your preference
define("SUBJECT_LINE", "Online Contact");

//enter the FULL name of the file that you want to return visitors to after they submit
define("REDIRECT_PAGE_NAME", "http://www.website.com/thankyoucontact.html");

HINT: If you are building this form for a client, put your own email in the "SEND_TO_EMAIL" define field while you are testing.

Upload this file to the same directory as the file that contains your form. You should be good to go!

Click here to try out the sample form emailed as HTML or click here to try out the sample form emailed as plain text. Questions and comments should be sent to jenny - at - whitewavedesigns.com.

White Wave Designs builds Email-Only Contact Forms that use this script for $5 per each form field/select value (excluding states and pre-built select lists). Contact White Wave Designs for more information.

<< ~ Page 3