PHP Form Tutorial

The tutorial is meant to help people who wish to have forms on their web sites (like a link submission form, for example) without using an ad-based service like Bravenet or Freedback. Please note that this IS written in PHP, and to use this script, your server must support PHP. Most paid sites do, but many free sites do not: check with your host before you try this script out. You must also have some basic experience with forms to try this; if you need a refresher, click here.

Here's the basic script:

Modify the following parts of the script:

YOUR E-MAIL ADDRESS GOES HERE: put the e-mail address you want the form info submitted to here

SUBJECT LINE GOES HERE: put the subject you want the forms sent to you under

field1, field2, etc.: these are all the input fields that contain the information visitors will submit. You can copy/paste the basic input code ($_POST['field'] . "\r" .) to get however many fields you need (you can also take off as many as you want, provided you leave at least one remaining). If I were using a form that asked visitors for their names, e-mail addresses, and locations, I'd have $_POST['name'] . "\r" ., $_POST['email'] . "\r" ., and $_POST['location'] . "\r" .. Note that hypens - do not work well in the form (note that I used "email" as a form field instead of "e-mail"). After you've gotten this taken care of, find where it says FROM HERE. Replace that with what you want the From part of the e-mail you receive to say. Make sure to leave the <> in!

Next, look for THANK-YOU PAGE HTML GOES HERE. This where you put the whole HTML code of the page you want visitors to see when they click submit.

Take the whole script and paste it into a text editor, such as NotePad. Click Save As, and under Save as type, select All files. Type in a name for your form (something like form-send works well), and end the name with .php.

Now upload the form to your server. It's easiest if you put it in the same directory that the page with the form on it will be in. Go to the page where you want the form on it. A sample form (my former newsletter form) would look like this:

"Form action" should equal the name you gave your script. The input name "email" would be the same as the field on the actual script. Make sure to end each input field with a space and a / forward slash (even the submit button). End the whole thing with </form>, upload the page with the form on it, and test it out. Does the e-mail come through the way you want it? If so, you're all set. If not, look through the instructions to see if you missed anything, tinker around with it, and try again. Good luck!