PHP Guestbook Script

Written By: Nick Tiberi

- 08 May 2006 -
















Description: In this tutorial we will create a simple but functional guestbook using PHP. All you need is a text editor and a web host that supports PHP. No MySQL is needed.

  1. Create the Form
  2. Handle the Data
  3. View Data Only

Create the Form

Open your text editor and create a new XHTML document. Save the file as "index.php." Now we're going to use some XHTML to create the form:

 id="form">
         method="post" action="guestbook.php">
        
for="Name">Name: type="text" id="Name" name="Name" />
for="Email">Email: type="text" id="Email" name="Email" />
for="Comments">Comments: id="Comments" name="Comments" class="input" rows="3" cols="25">
type="submit" value="Submit" />

href="viewguestbook.php">View Guestbook

You'll notice that there are references to two other files: "guestbook.php" and "viewguestbook.php." We will worry about those later.

If you view this in your browser, you'll notice that there is no styling to it whatsoever. Add this CSS code between the and tags of your XHTML document to spruce it up a bit:

If you don't understand all that, don't worry. Just plug it in and go! Now if you look at the page, you'll see a nice little form – but it doesn't do anything yet.

Next >>