After a lot of posts, I realised that there is not one tech post in my blog. So here comes the first tech post.
Creating a guest book is very simple in PHP. After playing around with PHP for sometime I wonder how easy it is for creating dynamic web applications. I have heard of a few drawbacks of PHP but for what I intend to use it, I have no problems. Below is a detailed description of the guest book application
If you do not have MySQL installed, download and install from http://dev.mysql.com/downloads/mysql/5.0.html. Once this is done, the database has to be setup to hold info from the guestbook form (which will be created shortly)
First, a database has to be created. Let the database be called guestdb. Use the following SQL statement to create the database. Login to MySQL. If you are running MySQL server on your desktop, your root password will not be set. You need a provide a password while logging in as root. Change the root password
mysqladmin -u root password <password>
Login as root and create a new database
create database guestdb;
Create a new user name for use with your guestbook.
grant all privileges on guestdb.* to guest@”%” identified by ‘guest’
The above statement tells MySQL to create a new user name called guest and with the password as guest. The user will have access to all the tables in guestdb. The user will be able to connect from any computer (host)
A table is required to hold the information that users leave on the guestbook. Let the table be guestbook. The SQL to create the table is
create table guestbook (ID INT NOT NULL AUTO_INCREMENT, Name VARCHAR(50),Email VARCHAR(100), Comment TEXT NOT NULL, Date DATETIME NOT NULL,PRIMARY KEY(ID));
A HTML form is required to capture info from the user. The form will be called gb.html
Once the form is submitted, the data should be captured and entered into the guestbook table. This is accomplished by gbprocess.php
To view the GuestBook, viewgb.php will be used
Happy Coding! Reuse of code permitted