Free Guestbook App| PowerASP.com providing a free version, we altered the code so we could use on our site. We've provide our code for FREE. Enjoy!! In the zip file there is an Access 2000 and Access 97 version database. Here is the code <% @language="vbscript" %> <% 'Dont Cache the page. response.expires = 0 response.expiresabsolute = Now() - 1 response.addHeader "pragma","no-cache" response.addHeader "cache-control","private" Response.CacheControl = "no-cache" %> <html> <head> <title>ASPFree.com Guestbook app</title> </head> <body> <% ACTION = Request.Form("ACTION") %> <% If ACTION = "Save" Then %> <!--#INCLUDE FILE="savemessage.asp"--> <% End If %>
<% If ACTION = "Save" Then %> <p align ="center"><font face="Arial">Thank You For Your Comments</font></p> <b> <% End If %>
<body bgcolor="#FFFFFF">
<form method="POST" action="default.asp"> <input type="hidden" name="ACTION" value="Save"><div align="center"><center><p><font face="Arial"><big><strong>Guest Book Entry</strong></big></font></p> </center></div><div align="center"><center><table border="0" bgcolor="#808080"> <tr> <td bgcolor="#800000"><strong><small><font color="#FFFFFF" face="Arial">NAME</font></small></strong></td> <td bgcolor="#C0C0C0"><input type="text" name="NAME" size="30"></td> </tr> <tr> <td bgcolor="#800000"><strong><small><font color="#FFFFFF" face="Arial">EMAIL</font></small></strong></td> <td bgcolor="#C0C0C0"><input type="text" name="EMAIL" size="30"></td> </tr> <tr> <td bgcolor="#800000"><strong><small><font color="#FFFFFF" face="Arial">HOMEPAGE URL</font></small></strong></td> <td bgcolor="#C0C0C0"><input type="text" name="URL" size="30" value="http://"></td> </tr> <tr> <td bgcolor="#800000"><strong><small><font color="#FFFFFF" face="Arial">MESSAGE</font></small></strong></td> <td bgcolor="#C0C0C0"><textarea rows="4" name="MESSAGE" cols="30"></textarea></td> </tr> </table> </center></div><div align="center"><center><p><input type="submit" value="Add To Guestbook"></p> </center></div> </form> <!--#include file="showmessages.asp"--> </body> </html>
*Save Messages Include file <!--#include file="conn.asp"--> <% NAME = Request.Form("NAME") MESSAGE = Request.Form("MESSAGE") EMAIL = Request.Form("EMAIL") URL = Request.Form("URL") IPAddy = request.servervariables("Remote_Addr") %> <% If URL = "http://" Then URL = "" End If %>
<% 'Declare all variables Dim conn Dim strDelSql Dim strSQL
'Open Connection to the database Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open strconn
'Delete any records that might contain Null data strDelSql = "DELETE FROM Guestbook WHERE (((Guestbook.Name)='') AND ((Guestbook.Email)='') AND ((Guestbook.Message)=''))" Conn.execute(strDelSql)
'Build Insert String strSQL = "INSERT INTO Guestbook(Name, Email, Date_Entered, URL, IP_Address, Message)" strSQL = strSQL & " SELECT " strSQL = strSQL & "'" & Name & "' as text1, " strSQL = strSQL & "'" & Email & "' as text2, " strSQL = strSQL & "'" & Date() & "' as text3, " strSql = strSQL & "'" & URL & "' as text4, " strSql = strsql & "'" & IPAddy & "' as text5, " strSQL = strSQL & "'" & replace(request("Message"), "'", "''") & "' as text6 " conn.execute(strsql) conn.close set conn = nothing %>
<% Sub TLdelaySec(DelaySeconds) SecCount = 0 Sec2 = 0 While SecCount < DelaySeconds + 1 Sec1 = Second(Time()) If Sec1 <> Sec2 Then Sec2 = Second(Time()) SecCount = SecCount + 1 End If Wend End Sub %>
<% TLdelaySec(4) %> Show Messages Include file--This part of the code is provided by PowerASP.com <!--#include file="conn.asp"--> <% ACTION = Request.Querystring("ACTION") %> <% PAGE = CInt(Request.Querystring("PAGE")) %>
<% RCOUNT = CInt(Request.Querystring("RCOUNT")) %> <% If RCOUNT = "" Then %> <% RCOUNT = "0" %> <% End If %>
<%
Dim CmdShowEntries Dim MySQL
'** Get initial recordset set conn = server.createobject("adodb.connection") conn.open strconn Set CmdShowEntries = Server.CreateObject("ADODB.Recordset") MySQL = "SELECT * FROM Guestbook WHERE (NOT (NAME IS NULL)) ORDER BY DATE_ENTERED DESC" CmdShowEntries.Open MySQL, conn, 3 %>
<% HOWMANY = 5 %>
<% '** Determine Page Size CmdShowEntries.PageSize = HOWMANY %>
<% If ACTION = "FORWARD" Then %> <% PAGE = PAGE + 1 %> <% RCOUNT = RCOUNT + HOWMANY %> <% For DACOUNT = 1 To RCOUNT %> <% CmdShowEntries.MoveNext %> <% Next %> <% End If %>
<% If ACTION = "BACK" Then %> <% PAGE = PAGE - 1 %> <% RCOUNT = RCOUNT - HOWMANY %> <% If RCOUNT <> 0 Then %> <% For DACOUNT = 1 To RCOUNT %> <% CmdShowEntries.MoveNext %> <% Next %> <% End If %> <% End If %>
<% If RCOUNT = "0" Then %> <% PAGE = 1 %> <p align="center"><font face="Arial">
<% If CmdShowEntries.RecordCount > 1 or CmdShowEntries.RecordCount = 0 Then %> <% =CmdShowEntries.RecordCount %> Messages Found <% Else %> <% =CmdShowEntries.RecordCount %> Message Found <% End If %> <br> <% If CmdShowEntries.RecordCount <> 0 And HOWMANY < CmdShowEntries.RecordCount Then %> Showing First <% = HOWMANY %> <% End If %> <br> </font></p> <% End If %>
<% If CmdShowEntries.RecordCount = 0 Then %> </BODY> </HTML> <% Response.End %> <% End If %>
<hr>
<div align="center"><center>
<table border="0" width="600">
<% y = 0 %> <% while NOT CmdShowEntries.EOF %>
<tr> <td bgcolor="#C0C0C0"><strong><font face="Arial"><%= CmdShowEntries("NAME") %></font></strong></td> <td bgcolor="#C0C0C0"><a href="mailto:<%= CmdShowEntries("EMAIL") %>"><font face="Arial"><%= CmdShowEntries("EMAIL") %></font></a></td> <td bgcolor="#C0C0C0"><font face="Arial"><a href="<%= CmdShowEntries("URL") %>" Target="_blank" ><%= CmdShowEntries("URL") %></a></font></td> </tr> <tr> <td bgcolor="#800000" colspan="3"><font color="#FFFFFF" face="Arial"><strong><%= CmdShowEntries("MESSAGE") %></strong></font></td> </tr> <tr> <td bgcolor="#C0C0C0" colspan="3"><strong><font face="Arial"><%= CmdShowEntries("DATE_ENTERED") %> IP ADDRESS <%= CmdShowEntries("IP_ADDRESS") %></font></strong></td> </tr> <tr> <td colspan="3" height="20"><strong><font face="Arial"> </font></strong></td> </tr>
<% CmdShowEntries.MoveNext %> <% y = y + 1 %> <% if y = HOWMANY then %> <% while NOT CmdShowEntries.EOF %> <% CmdShowEntries.MoveNext %> <% wend %> <% end if %> <% wend%>
</table> </center></div>
<br>
<div align="center"><center>
<table border="0" width="400"> <tr> <td width="200"><% If RCOUNT > 0 Then %> <form method="PUT" action="default.asp"> <input type="hidden" name="ACTION" value="BACK"> <input type="hidden" name="RCOUNT" value="<% =RCOUNT %>"> <input type="hidden" name="PAGE" value="<% =PAGE %>">
<p><font face="Arial"><input type="submit" value="Previous <% =HOWMANY %> Messages"></font></p> </form> <% End If %> </td>
<td width="200"><% If PAGE = CmdShowEntries.PageCount Then %> <% Else %> <form method="PUT" action="default.asp"> <input type="hidden" name="ACTION" value="FORWARD"> <input type="hidden" name="RCOUNT" value="<% =RCOUNT %>"> <input type="hidden" name="PAGE" value="<% =PAGE %>">
<p><font face="Arial"><input type="submit" value="More Messages"></font></p> </form> <% End If %> </td> </tr> </table> </center></div> |
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve. FREE! Go There Now!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, for an overview of Rational’s new software offerings and resources to help modernize and accelerate software innovation on i on Power Systems – while ensuring past application investments are protected and continue to grow. Learn how these solutions are helping customers extend their core i5/OS solutions toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects. FREE! Go There Now!
| | | | Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase. FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered! FREE! Go There Now!
| | | | Because access to government information continues to be an area of concern for many U.S. citizens with disabilities, the U.S. government enacted Section 508 of the Rehabilitation Act in 2001 to ensure that government agencies create accessible Web content, enabling all citizens to access the information they need. A fully accessible Web site makes Web content accessible to all individuals, including those with disabilities, who may be accessing Web content via a variety of user agents. Common user agents include standard Web browsers, text-only browsers, assistive devices and mobile devices such as cell phones or personal digital assistants (PDAs). FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications. FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic. FREE! Go There Now!
| | | | Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |