%
'
'Conn_String = "ubbs"
Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=d:\users\pierre\www\guest\gb.mdb"
'Number of Items per page
NumPages =5
'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 = Server.HtmlEncode(String)
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
%>
<%
End Sub
Sub SubAdmin
' Shows The Admin Screen
response.write ("hej henrik. Her kan koden indsættes")
End Sub
Sub SubShow
%>
gæstebog
<% ' 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 ORDER BY date_posted DESC" rs.Open strSql, my_conn, 1, 1 if rs.EOF and rs.BOF then ' Nothing Found %>Ingen beskeder i gæstebogen
<% 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 = 1 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") & " " & rs("IP") & " "%> |
" Response.Write "<< " Response.Write "< " Response.Write "> " Response.Write ">> " my_conn.close set my_conn = nothing %>
<%= PageNumber %> af <%= TotalPages %> sider
<% End Sub Sub SubDoIt ' Does the DB Update if Request.Form("name") = "" or Request.Form("message") = "" then %>Fejl!
Du skal indtaste navm og besked!
Gå tilbage og prøv igen.
<%
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 & ChkString(Request.ServerVariables("REMOTE_ADDR")) & "')"
'Response.Write StrSql
my_conn.Execute (StrSql)
my_conn.Close
set my_conn = nothing
%>
<%
End If
End Sub
%>