<%@ Language=VBScript %> <% frm_action = Request.Form("action") strName = "" strEmailAddr = "" strCity = "" strState = "" strCountry = "" strComments = "" strIPAddr = Request.ServerVariables("REMOTE_ADDR") & ", " & Request.ServerVariables("REMOTE_HOST") strDate = Date() invalidentry = 0 if frm_action = "Post" then strName = Request.Form("Name") strEmailAddr = Request.Form("EmailAddr") strCity = Request.Form("City") strState = Request.Form("State") strCountry = Request.Form("Country") strComments = Request.Form("Comments") strComments = Replace(strcomments, "'", "''") strComments = replace(strComments, cstr(chr(10)), " ") ' Error Handler if strName = "" then invalidentry = 1 end if if strEmailAddr = "" then invalidentry = 1 end if if instr(strEmailAddr,"@") = 0 then invalidentry = 1 end if if instr(strEmailAddr,".") = 0 then invalidentry = 1 end if if strComments = "" then invalidentry = 1 end if if invalidentry = 0 then set PPConn = server.createobject("adodb.connection") ' PConn.Open "DBQ=" & Server.Mappath("../db/patrickpearse") & ";Driver={Microsoft Access Driver (*.mdb)};" PPConn.open "patrickpearsedb","","" Set PPConn_rs = Server.CreateObject("ADODB.Recordset") sql = "INSERT into tblGuestbook(Name,Email,City,State,Country,Comment,IP_Addr,SubmitDate) " _ & "VALUES('" & strName & "','" & strEmailAddr & "','" & strCity & "','" & strState & "','" & strCountry & "','" & strComments & "','" & strIPAddr & "','" & strDate & "')" 'response.write "SQL: " & sql PPConn_rs.open sql, PPConn, adOpenStatic response.redirect("default.asp") end if end if %>

<% if invalidentry = 1 then %> One of the Required fields is incorrect.
Please check the information and post again.


<% end if %>
** Required Fields

**Name:
**Email:
City:
State/Province:
Country:
**Comment: