% Dim ip
ip =request.serverVariables("REMOTE_ADDR")%>
<%
Const NUMBER_OF_PAGES = 1
Dim intPreviousPage
Dim intCurrentPage
Dim strItem
' What page did we come from?
intPreviousPage = Request.Form("page")
' What page are we on?
Select Case Request.Form("navigate")
Case "< Back"
intCurrentPage = intPreviousPage - 1
Case "Next >"
intCurrentPage = intPreviousPage + 1
Case Else
' Either it's our first run of the page and we're on page 1 or
' the form is complete and pages are unimportant because we're
' about to process our data!
intCurrentPage = 1
End Select
' If we're not Signed then display the form.
If Request.Form("navigate") <> "Sign" Then %>
<%
For Each strItem In Request.Form
If strItem <> "page" And strItem <> "navigate" Then
If strItem <> intCurrentPage Then
Response.Write("" & vbCrLf)
End If
End If
Next
Select Case intCurrentPage
Case 1
%>
<%
Else
Dim guestbook
Dim Rs
Dim sql
Dim guest_ip
Function stripHTML(strtext)
dim arysplit,i,j, strOutput
arysplit=split(strtext,"<")
if len(arysplit(0))>0 then j=1 else j=0
for i=j to ubound(arysplit)
if instr(arysplit(i),">") then
arysplit(i)=mid(arysplit(i),instr(arysplit(i),">")+1)
else
arysplit(i)="<" & arysplit(i)
end if
next
strOutput = join(arysplit, "")
strOutput = mid(strOutput, 2-j)
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput,"<","<")
stripHTML = strOutput
End Function
If Trim(Request.Form("ImageField")) = Session("ImageNo") Then
'Response.Write "" & Request.Form("ImageField") & " "
'Create an ADO connection and recordset object
Set guestbook = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
'Set an active connection and select fields from the database
guestbook.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
sql= "SELECT sign_date, name, email, location, comments, guest_ip FROM guests;"
'Set the lock and cursor type
Rs.CursorType = 1
Rs.LockType = 3
Rs.Open sql, guestbook 'Open the recordset with sql query
Rs.AddNew 'Prepare the database to add a new record and add
Rs.Fields("sign_date") = Request.Form("sign_date")
Rs.Fields("name") = StripHTML(Request.Form("name"))
Rs.Fields("email") = StripHTML(Request.Form("email"))
Rs.Fields("location") = StripHTML(Request.Form("location"))
Rs.Fields("comments") = StripHTML(Request.Form("comments"))
Rs.Fields("guest_ip") = Request.Form("ip")
Rs.Update 'Save the update
Rs.Close
Set Rs = Nothing
Set guestbook = Nothing
Else
response.redirect("sign.asp")
End If
response.write "The form information was inserted successfully."
response.redirect("Index.asp")
'connect_todb.execute(sql2)
' Done. Close the connect_todb object
'Else
'Response.Write("*** WARNING: Data= " & sponsor_username & " " & sponsor_name & " already exists in database. ")
'Response.Write("*** WARNING: Data= " & student_username & " already exists in database. ")
'End IF
%>
<%
End If
%>