ASP

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old January 2nd, 2006, 07:18 PM
herong herong is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 3 herong New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Writing Your Own Guestbook in ASP - Part I

For the complete version of this tutorials, see URL
------------

Writing Your Own Guestbook in ASP - Part I


If you are interesting writing a guestbook in ASP on your Web site, you may learn from this tutorial. I wanted to provide a guestbook tool to allow visitors to share their comments with other visitors and myself. So I tarted
to put together a simple guestbook application in ASP with MS Access database. While doing this, I have recorded all interesting notes and formatted as a tutorial to share with you.

Let me first provide you some design highlights before going into any details.

Functional requirements:

hyBook should allow visitors to view all existing comments collected in the guestbook.

hyBook should allow visitors to enter new comments anonymously.

hyBook should organize comments by topics.

hyBook should allow Webmasters to manage topics and comments.

Technical highlights:

Two tables will be used in hyBook: "Topic" stores topics, and "Comment" stores comments. Both tables will be stored in a MS Access database file.

A single ASP page will be used for visitors to enter new comment and view existing comments.

Two ASP page will be used for Webmaster to manage topics and comments.

All ASP pages should be as secure as possible.

All ASP pages should be configurable to allow Webmaster to merge into existing Website layout and style.

Database Tables

1. "Topic" table will be named as "hyTopic" with the following fields:
Code:
ID - "Autonumber" type
Subject - "Text" type
Content - "Memo" type


2. "Comment" table will be named as "hyComment" with the following fields:
Code:
ID - "Autonumber" type
TopicID - "Number" type, foreign key pointing to "hyTopic" table.
Content - "Memo" type
Name - "Text" type
Email - "Text" type
Timestamp - "Date" type
IpAddress - "Text" type


Table names are prefixed with "hy" so that they can be merged easily with your existing databases if needed.


Configuration File

The easiest way to set up configuration files with ASP pages is to use include files. For hyBook, I used one include file, _config.inc, to maintain all configurable items:

Code:
<%
'  _config.inc 
'
'  Configuration file
'  hyBook version 2006.01.01
'  Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/
  
'  Database connection
   Dim ogConn
   Set ogConn = Server.CreateObject("ADODB.Connection")

'  Number of submits per IP per day 
   Dim ngSubmitLimit
   ngSubmitLimit = 10

'  Default topic ID
   Dim ngDefaultTopicID
   ngDefaultTopicID = 14

'  Page title
   Dim sgPageTitle
   sgPageTitle = "hyBook Demo"

'  Debugging flag
   Dim bgDebug, ogDebug 
   bgDebug = False
   Set ogDebug = Nothing

Sub dbConnect
   ogConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
      Server.MapPath("/cgi-bin/hyBook.mdb")
      
   If bgDebug Then
      Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
      Set ogDebug = oFileSys.OpenTextFile("\temp\hyBook.log", 8, True)
      ogDebug.WriteLine("Open data base connection.")
   End If
End Sub

Sub dbClose
   Set ogConn = Nothing

   If bgDebug Then
      ogDebug.WriteLine("Close data base connection.")
      ogDebug.Close
   End If
End Sub
%>


Note that:

All variables defined in _config.inc should be global variables so they become accessible in any functions in any ASP pages. A "Dim" statement is needed to make a variable global.

Database connection process should be a configuration item, because it is always different from one Web server to another.

I also included a debug flag in the configuration file to control printing debug information in a log file.

Page Layout Templates

In order for hyBook to be integrated into different into different Web site, where each of them may different page layout, I have designed hyBook page to be based on template include files. Here is how this design works.

1. Each ASP page will have a template include file inserted at the beginning.

2. The template include file provides code to control the page layout.

3. The page layout should have blank blocks where some ASP function calls will be placed.

4. Each ASP page should only implement those ASP functions called by the template.

For example, the following is a template include file in my hyBook demonstration package:
Code:
<%
'  Template file
'  hyBook version 2006.01.01
'  Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/

   opening
%>
<?xml version="1.0"?>
<html><head>
<title>hyBook - Demo</title>
<meta name="description" content="Demonstration page of hyBook 
- A simple guest book script"/> 
<meta name="keywords" content="hyBook, Guestbook, ASP">
<link rel="stylesheet" type="text/css" href="hyBook.css"/>
</head><body>

<center>
<%
   outputHeader
%>

<%
   outputBody
%>

<%
   outputFooter
%>


Powered by <a href=http://www.herongyang.com/hyBook/>hyBook</a></p>
</center>

</body></html>
<%
   closing
%>


Note that there are 5 ASP function calls placed in this template:

"opening" - Giving the ASP page a chance to do initialization work, like establishing database connection, and checking input data in the HTTP request.

"closing" - Giving the ASP page a chance to do closing up work, like closing database connection.

"outputHeader" - Allowing the ASP page to generate HTML code designed as the header block.

"outputBody" - Allowing the ASP page to generate HTML code designed as the body block.

"outputFooter" - Allowing the ASP page to generate HTML code designed as the footer block.

What's goes into the header block, the body block, and the footer block is up to the author of the page. Of course, if you don't use any of those blocks, just implement an empty function in the ASP page.

Also note that a CSS file, hyBook.css, is designed in hyBook to allow you control the appearance of individual HTML elements.


Guestbook Main Page
(To be continued)

Handling Data Submission Issues
(To be continued)

Webmaster Administration Page
(To be continued)

------------
For the complete version of this tutorials, see URL

Reply With Quote
  #2  
Old November 26th, 2009, 09:42 AM
deewanceclake deewanceclake is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Location: Burkina Faso
Posts: 2 deewanceclake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 11 sec
Reputation Power: 0
Send a message via ICQ to deewanceclake
What's up ****

What's up all and divers, I'm mod to the forum and valid wanted to look at hey. Expectantly I posted this in the deprecative cross-section!

Reply With Quote
  #3  
Old January 14th, 2011, 09:05 AM
Emboffvox Emboffvox is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Location: Bahrain
Posts: 1 Emboffvox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 sec
Reputation Power: 0
Send a message via ICQ to Emboffvox
Facebook
Tutorialized Forums - Reply to Topic

I just want to say Hi to Everyone!

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP > Writing Your Own Guestbook in ASP - Part I


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap