Form Processing with PHP

E-mailThis tutorial is intended for use with Macromedia Dreamweaver as a web design tool. The code will work with a different design tool or even a plain text editor, but references to Design view may not apply to other environments. Dreamweaver includes some very nice PHP integration and I recommend it strongly if you're using PHP to develop web sites.

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. The tutorial assumes only a very basic knowledge of PHP, but even that's not required. We'll start simple and build on the knowledge we gain to implement a full featured form to e-mail handler. The only thing really necessary is that you be fairly comfortable working in Code View.

We're not here to give point and click solutions. The scripts provided here are intended to be used as learning tools. They are not expected to be full-featured, ready to use, production scripts that you can simply upload and use. If that's what you're looking for, try At the time I'm writing this, in November of 2004, there are 320 of them listed. I'm quite sure one of them will work for you. Our goal here is to help you learn how it works, so that you can create your own custom script that does exactly what you want.

Lesson 1
Getting Started: Explains how to send an e-mail using PHP and how to process a simple form and send it.
Lesson 2
Simple Validation: Here we'll attempt to protect your script from spammers who would use it to send their annoying messages to people who don't want them and to validate the user's input.
Lesson 3
More complex Messages: Here we'll deal with dynamically assigning the recipient, sending to multiple recipients, and handling more types of user input.
Lesson 4
Generic scripts: This lesson will create a generic script that will e-mail the results of a form without knowing anything about the form. With this type of script, you can use a single script to process different forms.
Lesson 5
Sending files as attachments to e-mail messages.
Lesson 6
Sending e-mail as HTML.
Lesson 7
Protecting your script from unscrupulous spammers and checking quotation marks in form input.