Back to the forms.

Using the Website Contact Form Generator

You will create a form with a number of fields on it. This form page can be saved with a name like Contact.html or Form.html, doesn't matter what you call it.

Then copy the contents of the sample .PHP page between the <BODY> tags on a new page. Save the page as contact.php (case matters).

On your form page, make sure this line is on the end of the opening <FORM> tag line (action="contact.php").

Like this <form method="POST" action="contact.php">.

This is essential for the form to work. The name is case sensitive and must match the name on the PHP form handler file.

Then, perform the following edits on the contact.PHP file

Warning: IN ALL CASES, be sure not to delete existing commas, quotes, etc. They are all essential.

See illustration below for SECTION numbering.

IN SECTION 1

There are three variables, lines starting with a dollar sign ($).

$EmailFrom - is the email return address (leave as is or make one up). Not important for this project.

$EmailTo - is critical. It should be the address of the person to whom the results of the form will be sent. Use your email to test. Put in my email when you are submitting your project for grading so I can see if I get the form.

$Subject - is the the subject line the email receiver will see on the email when it arrives. Make it meaningful, like "Form from Nigel's web site", but customized to your site, not me.

IN SECTION 2

There are three lines starting with dollar signs ($). They work for the sample form which has three fields in it, Name, emailaddress and Comment. See how there is one line for each field? Note that the name is repeated at the beginning and the end of each line. You have to make the fields match your own form fields.

For each field name in your form, there should be a line here. Duplicate lines as needed and paste under the group until you have one line for each of your form names.

IN SECTION 3

There are three groups of three lines plus an opening line with nothing in it. Again, note how the three groups contain the field names from the sample form. You need to change this area of the file to match your form fields.

For each field name in your form, there should be 3 lines here. Three lines starting with $Body .=, where the first two have your field name and the third has just "\n" in it.

Duplicate groups of lines as needed and paste under the group until you have one set of three for each of your form names.

IN SECTION 4

All you have to do is rename the thankyou.htm file name to thankyou.html. When the user hits "Submit" on the form, this is the page they will go to. (Be sure this thank you page has your regular site menu on it also so it's not a dead end.)

Using the Website Contact Form Generator