PHP allows you to create dynamic web pages: web pages that do things differently depending on when or how someone visits your page, or that change depending on some other outside data. In this tutorial, I’m going to cover some of the very basics of using PHP to handle forms in your web pages. I’m going to assume that you know a little bit about HTML, but nothing about programming or PHP. If you aren’t familiar with HTML, you’ll want to go over the Web Writing Guide at http://hoboes.com/NetLife/Web_Writing/ first.
You’ll need a text editor of some kind; many web page editors have them built in; Dreamweaver does, for example. As I write this, you cannot use the text editor built-in to SeaMonkey. It will throw out your PHP code when you switch between WYSIWYG editing and text editing. If you want a dedicated text editor, NoteTab on Windows comes recommended by people I trust, and Fraise or Smultron on Mac OS X are great choices.
- Why use PHP?
- If you need to embed dynamic text into otherwise unchanging web pages, you’ll find PHP extremely useful. It was designed for this and it excels at it. You can easily create your web page as normal, with boilerplate text for the parts that need to be changed per visitor. Then, once you’ve designed the page, you can replace the boilerplate with PHP code to display the changing parts of the page.
- More information
- You can get more information about PHP, as well as the full PHP manual, at the PHP web site, http://php.net/. The PHP on-line manual is extremely useful: not only does it let you quickly look up any part of PHP, it also includes notes from people who use PHP about problems you might run into and how to fix them. When you’re looking at the official instructions for a function you’re having trouble with, do a search through the comments at the…
- The php extension
- This depends on how your server is set up, but your PHP web pages usually need to end in the extension “php”. This lets the server know that it needs to hand this page off to the “php” module before letting the visitor see the web page.