<% Response.Buffer = True %> <% 'declaring all database variables and opening connections Set dc = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") dc.Open "DBQ=" & Server.Mappath("db/database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" %> Baden African Boerboel Breeders

BOERBOELS FROM AFRICA TO YOU

<% ' this script adds a record to database openMethod = request.form ("openMethod") If openMethod = "postMessage" Then 'this line checks if the ASP file should post a message userDate = FormatDateTime(NOW) 'records the post date and time userName = request.Form ("userName") userCity = request.Form ("userCity") userMail = request.Form ("userMail") userURL = request.Form ("userURL") userMessage = request.Form ("userMessage") 'this function provides encoding to html format Function EncodeData(source) result1 = source result = "" for i = 1 to len(result1) resvalue="" if mid(result1,i,1)="'" then resvalue=resvalue+"''" if mid(result1,i,1)="|" then resvalue=resvalue+"¦" if mid(result1,i,1)="&" then resvalue=resvalue+"&" if mid(result1,i,1)="""" then resvalue=resvalue+""" if mid(result1,i,1)=chr(13) then resvalue=resvalue+"
" if resvalue<>"" then result = result + resvalue else result = result + Mid(result1, i, 1) next EncodeData = result End Function 'converts the data to HTML format using the EncodeDara function 'since DB fields can't be zero-length, in case they're empty, we'll set them to " " userName = EncodeData(userName) if NOT userCity = "" then userCity = EncodeData(userCity) else userCity = " " if NOT userMail = "" then userMail = EncodeData(userMail) else userMail = " " if NOT userURL = "" then userURL = EncodeData(userURL) else userURL = " " userMessage = EncodeData(userMessage) if len(userMessage) > 4096 then userMessage = Left(userMessage, 4096) End If 'this sets the message size limit to 4 kb: if it's more then 4kb, a part of it will be erased if userURL <> "" then if Left(UCase(userURL),7) <> "HTTP://" then userURL = "http://" & userURL End IF 'if user writes his url as "www.someurl.com" then it's replaced with "http://www.someurl.com" MYSQL = "SELECT guestbook.* FROM guestbook" 'selects the guestbook table in the database if NOT (userName = "" or userMessage = "" or userMail = "") then 'if all fields are valid, adds a record to the DB rs.Open MYSQL, dc, 1, 3 'opens the database rs.AddNew rs.Fields("userDate") = userDate rs.Fields("userName") = userName rs.Fields("userCity") = userCity rs.Fields("userMail") = userMail rs.Fields("userURL") = userURL rs.Fields("userMessage") = userMessage rs.Update response.Cookies("server")("name") = userName 'this code saves your name, mail, url and city as a cookie, so that users don't have to enter them the next time they use the guestbook response.Cookies("server")("email") = userMail response.Cookies("server")("URL") = userURL response.Cookies("server")("city") = userCity response.Cookies("server").Expires = DateAdd("m",1,Date) response.redirect ("guestbook.asp") 'redirects to the guestbook page End If End If %>

Please complete our guestbook
If you would like Attie to reply personally please send e-mail to: attiemkulu@mweb.co.za

 

Name*: " size="35" maxlength="64">

E-Mail:

" size="35" maxlength="128">

City:

" size="35" maxlength="64">

URL:

" size="35">

Message*:

   
<% MYSQL = "SELECT ID, userDate, userName, userCity, userMail, userURL, userMessage FROM guestbook ORDER by ID DESC" rs.Open MySQL, dc, 3, 1 %> <% 'this is the records counter and navigation stuff currentPage = request.queryString ("id") 'check what page to dysplay (this is used for nav) If currentPage = "" then currentPage = "1" End If pageSize = 10 'pageSize is the ammout of records per page to be dysplayed Records = rs.RecordCount 'this is the total ammount of records in the DB If Not (Records = 0) then 'if there are no records in the DB, server may report an error. I used the IF structure to prevent this error. rs.pageSize = pageSize rs.AbsolutePage = currentPage 'absolutePage is the page to be dysplayed - don't change it: it depeds on the user's choice End If pageNext = currentPage + 1 pagePrev = currentPage - 1 Pages = Records \ pageSize if Records mod pageSize then Pages = Pages + 1 End If %>
Pages: <% If Not pagePrev < 1 then %> Prev <% else %> Prev <% End If %> | <% While NOT pageNumber = Pages pageNumber = pageNumber + 1 %> <% if CInt (pageNumber) = CInt (currentPage) then %> <% = pageNumber %> | <% else %> <% = pageNumber %> | <% End If %> <% Wend %> <% if NOT pages < pageNext then %> Next <% else %> Next <% End If %>

Total entries: <% = Records %>

<% If Not (CInt(Records) = 0) then 'if there are no records in the database it doesn't go on dysplaying then and only sais that there are no records Do While (Not rs.EOF) and (currentRecords < pageSize) 'runs through the records and dysplays them currentRecords = currentRecords + 1 'counts currently dysplayed records %>

Name: <% = rs("userName") %> , City: <% = rs("userCity") %>
E-mail: "> <% = rs("userMail") %>
URL: ><%= rs("userURL") %>

Posted: <% = rs("userDate") %>

Message: <% = rs("userMessage") %>

<% rs.MoveNext Loop Else %>

No records found, be the first to post a comment!

<% End If %>

 

Contact us Boerboel Nutrition Boerboel training Choosing your Boerboel Boerboels and Children Boerboel Standard About Baden Boerboels Boerboel breeding stock upcoming Boerboel litters Hip dysplasia Boerboels character Boerboel health checks Boerboel nutrition dog diseases Boerboel history accidental training admin

 
<% 'closing connections and resetting all database variables rs.Close Set rs = Nothing dc.Close Set dc = Nothing %>