Overview

Goal of this tutorial (a set of lessons)

Get you to the point where you can create your own working “Request Info” forms in PHP.

Why I created this

One of THE first things that I found I needed on any of my customers’ websites was a Request Info form. I find that having a problem to solve and then creating the code for the solution is a great way to learn a language. But, I had difficulty with many of the forms examples as they are way too complex and the coding is way too clever.

Here we start off with the simplest form and grow into the complex and clever.

The Lessons

Why the silly numbering scheme for the lessons? Because I haven't thought through the entire syllabus. Therefore, I may want to insert a lesson between two existing ones. So, I thought I would leave some “space”.

Lesson 00

Is PHP available on your webserver?

Lesson 02

Your first request form. Very simple with two lines of input:: name, email. It then sends an email to you.

Lesson 07

Add some formatting, using a table and a Cascading Style Sheet to make the form prettier.

Lesson 10

Make one field (contactFirstName) required and add a test to ensure that data is entered (i.e, First Name is required).

Lesson 11

Add the ability to have a PopUp window to add explanatory notes.

Lesson 12

All three (3) fields are required.

Lesson 15

How to keep inputted data in form after you have an error message.

Lesson 17

Send the visitor to a “thank you” page after they click the submit button.

Lesson 18

Send the visitor a confirming email after they click the submit button.

Lesson 20

A better check for email address vailidity. Is the domain for real? And, what about PHP on Windows?

Lesson 22

Now we add: check boxes, radio buttons, pull down lists and a text area to our form.

Lesson 23

Making the form work better when magic quotes are enabled.

Lesson 25

Send data to a text file for later download into a spreadsheet.

Lesson 30

Upload a file and move to our own directory.

Lesson 32

Attach the uploaded file to an email.

My Background

PHP is my second “website backend processing” language. When I began building websites in 1995, I used whatever CGI script was available on the webserver. This meant simple forms where the input was emailed to a single recipient. Then, of course, my customers wanted “just a few changes” to their forms and that led me to examine the Perl code that controlled the backend processing.

After making slight modifications to Perl code, I realized that major changes were going to be very difficult. One thing I noticed about every Perl script that I looked at was that the code was cryptic and not commented at all.

Luckily, in 1998, I discovered HTML/OS from Aestiva. This language looked like BASIC and came with an integrated database. It made creating custom forms very easy. I still use HTML/OS today for over a dozen websites.

While I have found HTML/OS to be very powerful and easy-to-use, I noticed that PHP was getting all the press. So, I decided to learn PHP by creating a Request Info form.

I have been programming for 43 years. Almost 100% in Procedural languages and not Object-Oriented languages. My coding style will reflect that heritage.

 

Go To MarketingTactics home