SIGN OUR GUEST BOOK

<% 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("database") & ";Driver={Microsoft Access Driver (*.mdb)};" %><% ' this script adds a record to database openMethod = request.form ("openMethod") if openMethod = "postMessage" then 'this line checks if the.htm file should post a message USER_DATE = FormatDateTime(NOW) 'records the post date and time USER_NAME = request.Form ("USER_NAME") USER_CITY = request.Form ("USER_CITY") USER_MAIL = request.Form ("USER_MAIL") USER_URL = request.Form ("USER_URL") USER_MESSAGE = request.Form ("USER_MESSAGE") if (USER_NAME = "" or USER_MESSAGE = "" or USER_MAIL = "") then 'this code dysplays an error message if user doesn't fill in the "*" marked fields: name, e-mail and Message response.write ("NAME, MAIL and MESSAGE fields must be filled!
") & VBCRLF End IF if USER_CITY = "" then USER_CITY = "nowhere" End If 'USER_CITY ain't a "must_fill" so if it's empty, it's simply replaced with a "nowhere" if USER_URL = "" then USER_URL = "none" End If 'same as with USER_CITY: replaced with "none" if not entered by user if len(USER_MESSAGE) > 4096 then USER_MESSAGE = Left(USER_MESSAGE, 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 USER_URL <> "" then if Left(UCase(USER_URL),7) <> "HTTP://" then USER_URL = "http://" & USER_URL End IF 'if user writes his url as "www.someurl.com" then it's replaced with "http://www.someurl.com" MYSQL = "SELECT GBOOK.* FROM GBOOK" 'selects the guestbook table in the database if NOT (USER_NAME = "" or USER_MESSAGE = "" or USER_MAIL = "") 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("USER_DATE") = USER_DATE rs.Fields("USER_NAME") = USER_NAME rs.Fields("USER_CITY") = USER_CITY rs.Fields("USER_MAIL") = USER_MAIL rs.Fields("USER_URL") = USER_URL rs.Fields("USER_MESSAGE") = USER_MESSAGE rs.Update response.Cookies("server")("name") = USER_NAME '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") = USER_MAIL response.Cookies("server")("URL") = USER_URL response.Cookies("server")("city") = USER_CITY response.Cookies("server").Expires = DateAdd("m",1,Date) rs.Close Set rs = Nothing dc.Close Set dc = Nothing response.redirect ("guestbook.htm") 'redirects to the guestbook page End If End If %>
Name*:
E-Mail*:
City:
URL:
Message*:
  

©2003 Al Shalan Co. All Rights Reserved       

       Designed by Solutions Soft Net 2003