(© 1997-2008 by Francisco Panizo Beceiro)

Se você quer uma Ajuda Específica para o seu caso, proceda como indicado:
clique Suporte, e envie a sua dúvida (para cadastrados no CLUBE DO HELP DESK)
ou envie sua dúvida para nosso Super Fórum )

O Site para os Amantes da Velocidade

Seção ASP da abcDICAS.com.br

A S P
Dicas de Uso para a Construção de Páginas Dinâmicas


 ASP: Códigos Prontos... 
    Aqui você encontra vários códigos prontos para usar, todos em ASP 
    Você aprende a usar essa poderosa ferramenta de programação em programas úteis

Códigos Prontos em ASP

Guestbook :: médio / intermediário ::

Baixe aqui nosso Guestbook


O código à seguir foi retirado do site ASPFree.com numa versão free
O arquivo para download contém duas versões da base-de-dados: Access 2000 e Access 97.

O código está abaixo. Aproveite e aplique em seu site em ASP:

<% @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--

<!--#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") %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IP ADDRESS&nbsp;<%= CmdShowEntries("IP_ADDRESS") %></font></strong></td>
</tr>
<tr>
<td colspan="3" height="20"><strong><font face="Arial">&nbsp;</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>

 

Veja também: Comandos Básicos de ASP...

PESQUISA ON-LINE:
Vote em nossa Enquete OnLine

Atenção: não temos condição de dar suporte direto para todos os visitantes; use nosso Super Fórum Web Design para poder enviar suas dúvidas. O registro é gratuito!
Para um suporte diferenciado use o nosso Clube do Help Desk.


| Suporte | Cadastro | Consultoria | Quem Somos |