%
'
' Welcome to the ASP Resources Guest Book.
' This is a very simple script to configure, just fill in the below values
' To change the look of this Guest Book use any HTML Editor and cut and paste
' the section you want to modify.
' Take a backup first just to make sure!
' Your Connection String to your DB, either using DSN or DSN Less
'Conn_String = "ubbs"
Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("guestbook.mdb")
'Number of Items per page
NumPages =10
'Thats it!!!!!!
'Function to check validity of string to be put in DB
' It first checks the string is not empty, then
' Replaces the singe ' with a double ' ('') to stop errors
Function ChkString(string)
if string = "" then string = " "
ChkString = Replace(string, "'", "''")
End Function
'Function to format the result of a memo field.
' Replaces Linefeeds with
Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), "")
String = Replace(String, CHR(10) & CHR(10), "
")
String = Replace(String, CHR(10), "
")
FormatStr = String
End Function
Sub SubPost
' Shows The Form to Post Message
%>
Guestbook signing
<% End Sub Sub SubAdmin ' Shows The Admin Screen End Sub Sub SubShow %> <% ' Shows the message set my_conn= Server.CreateObject("ADODB.Connection") set rs = Server.CreateObject("ADODB.Recordset") my_Conn.Open (conn_string) StrSql = "SELECT * FROM gbook" rs.Open strSql, my_conn, 1, 1 if rs.EOF and rs.BOF then ' Nothing Found %>
No One has signed the book
<% exit Sub End If ' Something found TotalRows = rs.RecordCount rs.PageSize = NumPages TotalPages=RS.PageCount select case Request.QueryString("move") case "first" pageNo = 1 ' First case "previous" pageNo = cint(Session("page_num")) - 1 ' Next case "next" pageNo = cint(Session("page_num")) + 1 ' Previous case "last" pageNo = TotalPages ' Last case Else PageNo = TotalPages End Select if cint(PageNo) < 1 then PageNo = 1 if cint(PageNo) > TotalPages then pageNo = TotalPages RS.AbsolutePage = PageNo PageNumber=PageNo Session("page_num") = PageNo HowMany = 0 Response.Write "|
<%= FormatStr(rs("message")) %> "><%=rs("name")%> " target="_blank"><%=rs("home_page")%> <%=rs("date_posted") & " - " & rs("country") %> |
" Response.Write "<< " Response.Write "< " Response.Write "> " Response.Write ">> " my_conn.close set my_conn = nothing %>
<%= PageNumber %> of <%= TotalPages %>
<% End Sub Sub SubDoIt ' Does the DB Update if Request.Form("name") = "" or Request.Form("message") = "" then %>Error Signing The Guest Book
You must add a message and use your name!
Use your Browsers Back Button to Correct.
<%
Else
set my_conn= Server.CreateObject("ADODB.Connection")
my_conn.Open (conn_string)
strSql = "insert into GBook (Name, Home_page, email, message, Country, ip ) values ('"
strSql = StrSql & ChkString(Request.Form("name")) & "', '"
strSql = StrSql & ChkString(Request.Form("HP")) & "', '"
strSql = StrSql & ChkString(Request.Form("email")) & "', '"
strSql = StrSql & ChkString(Request.Form("message")) & "', '"
strSql = StrSql & ChkString(Request.Form("Country")) & "', '"
strSql = StrSql & Request.ServerVariables("REMOTE_ADDR") & "')"
'Response.Write StrSql
my_conn.Execute (StrSql)
my_conn.Close
set my_conn = nothing
%>
Thank you for signing the Guestbook
Back To Guestbook
Sign Guestbook View Guestbook |
return to main |
||||
<% select case Request.QueryString("mode") case "post" Call SubShow ' Call SubPost case "admin" Call SubShow ' Call SubAdmin case "doit" Call SubShow ' Call SubDoIt case "show" Call SubShow Case Else Call SubShow End Select %> |
|||||
|
© 2001 Siang & Annie. All rights reserved. Use of this site assumes acceptance of site policy. |
|||||