Using htmlArea and a Database to Maintain Content on a Website
If you wish to develop a website that others can contribute to, one option is to have text files sent as e-mail attachments, convert these to HTML and then upload the file. There is, however, a better way! If the people making submissions to your site are capable of using a word processor then things can be done much more efficiently. This article will show you how to use a free component called htmlArea and a database to handle the addition and display of content on your website. Some knowledge of HTML, databases and server-side scripts is assumed.
Using htmlArea and a Database to Maintain Content on a Website - Download and Install (Page 2 of 4 )
Excellent installation instructions are provided by interactivetools at their site so follow them and install htmlArea. However, there is one change you will probably want to make. If you follow the instructions given in the link above, you will need to place any page that uses htmlArea in the “htmlarea” directory. It is much more likely that you will want to access this control from a page in your server’s root directory. To do so, change the line of code that reads, _editor_url = ""; to _editor_url = "htmlarea/"; .
You can embed an htmlArea control that will work from your root directory using the following code:
Save this code, upload it to your server’s root directory and try it out. If you’ve done everything correctly you should see an htmlArea in place of the textarea named “contents”. Try out the various features and see what it is capable of.
Database Table
Let’s define the database table that will store the contents of an htmlArea. We’ll name the table “items” and give it the following structure:
Field Name
Data Type
Properties
id
int(11)
PRIMARY KEY
title
varchar(35)
Not Null
topic
varchar(35)
Not Null
author
varchar(15)
Not Null
contents
text
Not Null
whenadded
timestamp
reviewed
tinyint (4)
A few more fields than you imagined perhaps, but they all do serve a purpose. The “id” field will be a unique identifier and should probably be “auto_increment” type. “title” and “author” are self explanatory and “contents” will hold what’s typed into the htmlArea. The ‘whenadded’ field is a ‘timestamp’ data type so it will record the date and time that a record is added. Depending upon your needs, the ‘reviewed’ field may or may not be necessary but it will allow you to vet (preview) content before it is posted to your site. For instance, a where clause in your SQL such as, “WHERE reviewed =1”, would keep items not yet reviewed from showing up on your site.