Using Dreamweaver and PHP to send form results in an email

The form is a primary way to get web interactivity and structured communication. Dreamweaver has a robust and superior implementation of HTML forms. Forms enable user not only to read information passively from the screen, but also to send information back.

One of the more common questions is how to submit a form to send information in an e-mail. Using PHP, it's really very easy. Here we'll learn about processing forms to send e-mail using PHP.

Getting started with forms in Dreamweaver

I am using Dreamweaver MX 2004 but the options are almost same in the old and latest releases of Dreamweaver. We will be making a simple contact form and will deliver the results in an email using a PHP script.

Step 1: Create a form

We have created a simple form with four form fields as:

Name (text field)

Last name (text field)

Email address (text field)

Comments (textarea)

Step 2: PHP Script for processing the form results

We will use the PHP to send our form results through an email.

Copy and save this code in a file sendresults.php and set the following parameters the according to your requirements.

$subject (Subject of email sent to you)

$emailadd (Your email address. This is where the form information will be sent)

$url (Where to redirect after form is processed. )

$req (Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.)

Step 3: Pointing your form to the PHP script to process it

Select the form and in form properties you will see the following attributes.

The Name attribute is very clear gives your form a name. We have given our form name as Contact form.

The Action attribute determines what should be done with the form content. Most commonly, action is set to a URL for running a specific web application or for sending email.

Here you will give the URL where you saved your sendresults.php file
Example www.yourdomain.com/sendresults.php

The Method attribute tells the browser or the web server how to present the form contents to the application that will process the form. “POST” in the Method window indicates that the information in the form will be passed to the program processing the form as standard input.
Give method=POST

Save your form and test it.

Points to remember:

In the form properties, Action=URL of your sendresults.php file and Method=POST

Editing the following parameters in sendresults.php file:$subject, $emailadd, $url, $req