Table of contents for Contact Form

  1. Creating a contact form using classes part 1

Recently I was asked at work to build a PHP email contact form that could do some specific things.

  • Allow the user to choose different departments/emails to send their submission to
  • Allow the user to input specific things into boxes such as telephone number, order ID
  • Be easy to extend so a non programmer could add an extra input at a later date

Then there were a few things I wanted to do.

  • Use classes to separate logic from layout
  • Clean and validate all input

Now there’s a lot of websites that show you how to do email forms, but most just send a users email address, name and message via post to a separate PHP file and then compose and email. While this is nice, simple and works it doesn’t allow for all the things that was asked and I felt should be done.

In part 2 I’ll show you how I started to build my classes.