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! | David Barnes, Lead Evangelist for IBM Emerging Internet Technologies 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!
| | | | CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
| | | | Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications. FREE! Go There Now!
| | | | Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
| | | | Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
| | | | This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
| | | | Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |