Adding an Email Form Using Dreamweaver

While surfing the internet, you must have noticed that quite a number of websites has some means through which visitors can contact the webmaster. Some will provide you with an email address so that you can reach them through it, while majority today uses a web form such as a “Contact Form” or a “Feedback Form” that visitors can fill to get in touch with the person who runs the website.

Why You Cannot Just Simply code an HTML Form and expect it Would Work

To a newcomer, web forms are really tricky. Quite a number of new webmasters think that they can simply code an HTML form using Dreamweaver, and would work automatically. Their troubles begin when they test in a web browser and find nothing happens when they click the send button. The truth is, nothing really happens!

It is important to understand that web forms, work like a component of a system made of many different parts. A form would have at least two parts: The HTML form and a back end script. The moment you click on the “Send” button, your message is relayed to a computer program, a script that runs on the Form site. The Form back-end script would then take the message and format it to an email message and finally delivers it to the PHP interpreter- yet another program found on your site. The PHP interpreter has a crucial role to play in the passing of the email to a program called mail processing program available on your host.

What you need for a working web form

If your web form has to function correctly, you will require a web host which will allow you to run PHP scripts. That however is not all. If, for instance you need to be able to run PHP emailing scripts, then your web host should configure their servers to send email. Understand that when a web host implies that PHP is enabled, it does not mean that the PHP email scripts are enabled. Bad web hosts particularly the free ones, do not allow PHP scripts to send mails.

Generally, if you need your form to function well, then getting a highly rated commercial web host is the best option.

Now that you have to basics of a working web form, let us proceed to build one.

Designing your form in Dreamweaver

Designing the form in Dreamweaver is easy. Dreamweaver comes with a set of built-in options to enable you build the forms quickly. Here is a tutorial that takes you step-by-step: Dreamweaver email form tutorial.

The PHP Script for Emailing the Form Data

Once you have designed the HTML part of the form, what you need is the back-end script. PHP has a number of functions and features to handle form data. The simplest is the php mail() function. Here is some PHP sample code :

This is the PHP back-end script that processes the form submission.
    echo "error; you need to submit the form!";
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];

//Validate first
    echo "Name and email are mandatory!";
$email_from = '';
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name. Email: $visitor_email\n".
    "Here is the message:\n $message".

$to = "";

//Send the email!
//done. redirect to thank-you page.
header('Location: thank-you.html');

[Note: PHP emailing code thanks to html form guide here]