Creating a News management system (Part 1)

This tutorial will take you through the process of creating a basic news management system in a step by step manner. If you intend to run the code on your own computer you will need IIS 4 or above or PWS working and running. Have a look at our tutorials on 'Installation' if you need to install either of these. Alternatively if you intend to run the code on your hosting company's server make sure they support ASP. You will also need a copy of Microsoft Access.

The files we are using are:

1) Microsoft Access database 'News.mdb'.
2) 'login.asp' - This will be our password protected login page.
3) 'admin_navigation.asp' - This is an include file which we will include in our admin files to provide a navigation system.
4) 'display_news.asp' - This will display all the news to our visitors and it's the only page we want our visitors to access.
5) 'add_news.asp' - The administrator can add more news.
6) 'insert_news.asp' - This page inserts newly added news into the database.
7) 'del_all.asp' - This page will let us select which news to delete.
8) 'delete_record.asp' - This page will delete the news.
9) 'edit_all.asp' - This page will let us select which news to edit.
10) 'edit_record.asp' - This page will let us edit the news.
11) 'update_record.asp' - This page will update the news.

Our first step is to create a folder called 'news' which will house all our files. You will also need to create two subfolders 'admin' and 'db'. The admin folder will hold the admin files ('login.asp', 'admin_navigation.asp', 'add_news.asp', 'insert_news.asp', 'del_all.asp', 'delete_record.asp', 'edit_all.asp', 'edit_record.asp, 'update_record.asp') which only the administrator will be able to access and the 'db' folder will house the database. When you installed PWS or IIS an 'Inetpub' folder should have been created on your hard drive with the sub folder 'wwwroot'. Locate this folder i.e. 'wwwroot' (the default is C:\inetpub\wwwroot) and inside it create a new folder called 'news'. If you intend to simply upload the code to your webspace on your hosting company's server then you can save the code anywhere though just keep the file structure as is.

First let's create an Access 2000 database called 'news.mdb'

Click Start - Programs- Microsoft Access and select the 'Blank Access Database' option and then click ok.

Access Database

You will be prompted as to what to call the database and where to save it. Call the database 'news.mdb' and save it in the folder 'db' that we just created.
Next click on 'New' and then on 'Design View'.

Create Database

Now we are going to create the fields of the table 'tblNews' and select their datatypes . There will be 4 fields.

Database fields

The 'tblNews' table fields:

1. Call the first field 'ID' and select Autonumber, this will ensure the uniqueness of each record. An autonumber will be automatically assigned to each new row added. This number will increase by 1 each time you add a new record.
2. Call the second field 'headline' and select text. Notice the 'Allow Zero Length', you can set this to 'Yes' for the fields 2 and 3.
3. Call the third field 'news_story' and select memo as this can then hold more than 255 characters.
4. Call the fourth 'story_date' and select Date/Time.

Now that we have created our 'news.mdb' database make sure you populate the table 'tblNews' with some records.

I have just filled in 3 records though you can fill in as many as you like. Try to fill in about 5 or 6.


Having created the database we will now create the password protected login page for the administration area of the system.

ASP/.NET Hosting

ASP.NET Web Hosting – 3 Months Free!

MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.