Website Feedback

<% Flag = request.form("Flag") If IsEmpty(Flag) or Flag = "" then %>

Sign the SARG Guestbook

Note: * indicates a required field

*Name:
*City:
 County:
*Country:
 Email:
Comments:
  
<% End If If Flag = 1 then If IsEmpty(request.form("Name")) or request.form("Name")="" then response.write "
" response.write "


You must enter a name.
" response.write "

" response.write "" response.write "
" response.end Else Name = request.form("Name") End If If IsEmpty(request.form("City")) or request.form("City")="" then response.write "
" response.write "


You must enter a City.
" response.write "

" response.write "" response.write "
" response.end Else City = request.form("City") End If ' we won't require a state State = request.form("State") If IsEmpty(request.form("Country")) or request.form("Country")="" then response.write "
" response.write "


You must enter a Country." response.write "

" response.write "" response.write "
" response.end Else Country = request.form("Country") End If Email = request.form("Email") If request.form("URL")="http://" then URL = "" Else URL = request.form("URL") End If If IsEmpty(request.form("Comments")) or request.form("Comments")="" or request.form("Comments")=" " then response.write "
" response.write "


Don't forget to enter your comments!" response.write "

" response.write "" response.write "
" response.end Else Comments = request.form("Comments") Comments = Replace(Comments, Chr(34), "''") Comments = Replace(Comments, vbCrLf, "
") End If Flag = request.form("Flag") %>

Here is the information you're submitting. If you would like to make changes, please use the appropriate button below, or use the other button to submit this entry as it is.

Name: <%= Name %>
City: <%= City %>
State: <%= State %>
Email: <%= Email %>

Comments: <%= Comments %>

 
<% End If If Flag = 2 then Today = Now() Name = request.form("Name") Name = Replace(Name, "'", "''") Name = Replace(Name, Chr(34), "''") City = request.form("City") City = Replace(City, "'", "''") State = request.form("State") Country = request.form("Country") Country = Replace(Country, "'", "''") Email = request.form("Email") URL = request.form("URL") Comments = request.form("Comments") Comments = Replace(Comments, "'", "''") ' ok now we've got our data so let's ship it off to the database set conn = server.createobject("adodb.connection") ' **** change DSN name if you're using a DSN and you've named it differently 'conn.open "guestbook" ' **** DSN-less connection: comment out above line and uncomment the ' **** Code between "Begin" and "End" ' **** BEGIN DSN-LESS CONNECTION CODE DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("guestbook.mdb") conn.Open DSNtemp ' **** END OF DSN-LESS CONNECTION CODE ' **** Note: If using a DSN-less connection, make sure to change server.mappath above to ' **** reflect the actual location of the guestbook database file. ' **** The above will work if the database file is at the webserver root. ' **** See readme.txt for further information ' **** the following line would be used ONLY if you use a system DSN! ' conn.Open "guestbook" 'Catch the dirty spammers! BannedWords = "pharmacy,webmasters,href,http,www,HerboMart" BanArray = split(BannedWords,",") BanIt = "Negative" For each bannedword in BanArray If instr(Comments,bannedword)>0 then BanIt = "Positive" End If Next 'f If BanIt = "Negative" then SQLstmt = "INSERT INTO Guestbook (Name,City,State,Country,Email,IP,URL,Comments)" SQLstmt = SQLstmt & " VALUES (" SQLstmt = SQLstmt & "'" & Name & "'," SQLstmt = SQLstmt & "'" & City & "'," SQLstmt = SQLstmt & "'" & State & "'," SQLstmt = SQLstmt & "'" & Country & "'," SQLstmt = SQLstmt & "'" & Email & "'," SQLstmt = SQLstmt & "'" & Request.Servervariables("REMOTE_HOST") & "'," SQLstmt = SQLstmt & "'" & URL & "'," SQLstmt = SQLstmt & "'" & Comments & "'" SQLstmt = SQLstmt & ")" Set RS = conn.execute(SQLstmt) If err.number>0 then response.write "VBScript Errors Occured:" & "

" response.write "Error Number=" & err.number & "

" response.write "Error Descr.=" & err.description & "

" response.write "Help Context=" & err.helpcontext & "

" response.write "Help Path=" & err.helppath & "

" response.write "Native Error=" & err.nativeerror & "

" response.write "Source=" & err.source & "

" response.write "SQLState=" & err.sqlstate & "

" end if IF conn.errors.count> 0 then response.write "Database Errors Occured" & "

" response.write SQLstmt & "

" for counter= 0 to conn.errors.count response.write "Error #" & conn.errors(counter).number & "

" response.write "Error desc. -> " & conn.errors(counter).description & "

" next else response.write "

" response.write "Thank you! Your entry has been added.

" response.write "" response.write "View Guestbook" end if Else Response.write("Post rejected as spam.") End If Conn.Close Set conn = nothing ' ***************************************************************** ' The following section of code sends email to the guestbook owner ' when somebody signs the guestbook. If you don't want this feature, ' just remove this block. Please note that this will ONLY work on ' NT SERVER with built-in SMTP!! On other systems, please see ' http://www.attitude.com/users/kathi/asp/tools.html for a list of ' components, including email components ' ****************************************************************** Set Mail = CreateObject("CDONTS.Newmail") ' get the sender's address, and if empty, put your own If request("email")="" then Sender = "Server@Surrey-arg.org.uk" ' put your email address here Else Sender = request("email") End If Mail.From = Sender Mail.To = "Steve@Surrey-arg.org.uk.com" ' put YOUR email address here Mail.Subject = "New Guestbook Entry" ' you can change this to whatever you'd like Msg = "Name: " & request("name") & Chr(10) Msg = Msg & "City: " & request("city") & Chr(10) Msg = Msg & "State: " & request("State") & Chr(10) Msg = Msg & "Country: " & request("Country") & Chr(10) Msg = Msg & "Comments:" & Chr(10) Msg = Msg & request("Comments") Mail.Body = Msg Mail.Send Set Mail = Nothing End If %>