home *** CD-ROM | disk | FTP | other *** search
- <html>
- <head>
- <title>My Guestbook</title>
- <!-- scripting , html copyright 1998 Kathi O'Shea ------->
- <!-- email info@web-savant.com for custom web development --->
- <!-- see readme.txt in zip file for modification and ---->
- <!-- redistribution info -------------------------------->
- </head>
- <body bgcolor="black" text="#C5BE60" topmargin=0 leftmargin=0>
- <center>
- <%
- Flag = request.form("Flag")
- If IsEmpty(Flag) or Flag = "" then
- %>
- <font face="times new roman">
- <i><h1>Sign My Guestbook</h1></i>
- <font face="arial" size=2>
- <b><i>Note:</i> * indicates a required field</b>
- </font>
-
- </font>
- <p>
- <table width=500 border=0>
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b>*Name:</b>
- </font>
- </td>
-
- <td width=400>
- <form action="sign.asp" method="post">
- <input type="text" name="Name" size=30>
- </td>
- </tr>
-
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b>*City:</b>
- </font>
- </td>
-
- <td width=400><input type="text" name="City" size=30></td>
- </tr>
-
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b> State:</b>
- </font>
- </td>
-
- <td width=400><input type="text" name="State" size=30></td>
- </tr>
-
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b>*Country:</b>
- </font>
- </td>
-
- <td width=400><input type="text" name="Country" size=30></td>
- </tr>
-
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b> Email:</b>
- </font>
- </td>
-
- <td width=400><input type="text" name="Email" size=30></td>
- </tr>
-
- <tr>
- <td width=100>
- <font face="arial" size=2>
- <b> URL:</b>
- </font>
- </td>
-
- <td width=400><input type="text" size=30 name="URL" value="http://"></td>
- </tr>
-
- <tr>
- <td valign="top" width=100>
- <font face="arial" size=2>
- <b>Comments:</b>
- </font>
- </td>
-
- <td width=400>
- <textarea name="Comments" cols=30 rows=5 wrap="virtual">
- </textarea>
- </td>
- </tr>
-
- <tr>
- <td width=100> </td>
- <td width=400><br>
- <input type="submit" value="Submit">
- <input type="hidden" name="Flag" value=1>
- <input type="reset" value="Clear"></form>
- </td>
- </tr>
-
- </table>
- <%
- End If
- If Flag = 1 then
- If IsEmpty(request.form("Name")) or request.form("Name")="" then
- response.write "<center><font face='arial' size=4>"
- response.write "<p><br><b>You must enter a name.</b></font>"
- response.write "<form>"
- response.write "<input type='button' value='Retry' onclick=history.back()>"
- response.write "</form>"
- response.end
- Else
- Name = request.form("Name")
- End If
-
- If IsEmpty(request.form("City")) or request.form("City")="" then
- response.write "<center><font face='arial' size=4>"
- response.write "<p><br><b>You must enter a City.</b></font>"
- response.write "<form>"
- response.write "<input type='button' value='Retry' onclick=history.back()>"
- response.write "</form>"
- 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 "<center><font face='arial' size=4>"
- response.write "<p><br><b>You must enter a Country.</b>"
- response.write "</font><form>"
- response.write "<input type='button' value='Retry' onclick=history.go(-1)>"
- response.write "</form>"
- 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 "<center><font face='arial' size=4>"
- response.write "<p><br><b>Don't forget to enter your comments!</b>"
- response.write "</font><form>"
- response.write "<input type='button' value='Retry' onclick=history.go(-1)>"
- response.write "</form></center>"
- response.end
- Else
- Comments = request.form("Comments")
- Comments = Replace(Comments, Chr(34), "''")
- Comments = Replace(Comments, vbCrLf, "<br>")
- End If
- Flag = request.form("Flag")
-
- %>
- <table width=400 border=0>
- <tr>
- <td width=400>
- <font face="arial" size=2>
- <br>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.
- <br>
- <br><b>Name:</b> <%= Name %>
- <br><b>City: </b> <%= City %>
- <br><b>State: </b> <%= State %>
- <br><b>Email: </b> <%= Email %>
- <br><b>URL: </b> <%= URL %>
- <p><b>Comments: </b> <%= Comments %>
- <form action="sign.asp" method="post">
- <input type="hidden" name="Name" value="<%= Name %>">
- <input type="hidden" name="City" value="<%= City %>">
- <input type="hidden" name="State" value="<%= State %>">
- <input type="hidden" name="Country" value="<%= Country %>">
- <input type="hidden" name="Email" value="<%= Email %>">
- <input type="hidden" name="URL" value="<%= URL %>">
- <input type="hidden" name="Comments" value="<%= Comments %>">
- <input type="hidden" name="Flag" value=2>
- <input type="submit" value="Yes, Submit it!">
- <input type="button" value="Let's Try Again" onClick="history.go(-1)">
- </form></font>
- </td>
- </tr>
- </table>
- <%
- 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"
-
- SQLstmt = "INSERT INTO Guestbook (Name,City,State,Country,Email,URL,Comments)"
- SQLstmt = SQLstmt & " VALUES ("
- SQLstmt = SQLstmt & "'" & Name & "',"
- SQLstmt = SQLstmt & "'" & City & "',"
- SQLstmt = SQLstmt & "'" & State & "',"
- SQLstmt = SQLstmt & "'" & Country & "',"
- SQLstmt = SQLstmt & "'" & Email & "',"
- SQLstmt = SQLstmt & "'" & URL & "',"
- SQLstmt = SQLstmt & "'" & Comments & "'"
- SQLstmt = SQLstmt & ")"
-
- Set RS = conn.execute(SQLstmt)
- If err.number>0 then
- response.write "VBScript Errors Occured:" & "<P>"
- response.write "Error Number=" & err.number & "<P>"
- response.write "Error Descr.=" & err.description & "<P>"
- response.write "Help Context=" & err.helpcontext & "<P>"
- response.write "Help Path=" & err.helppath & "<P>"
- response.write "Native Error=" & err.nativeerror & "<P>"
- response.write "Source=" & err.source & "<P>"
- response.write "SQLState=" & err.sqlstate & "<P>"
- end if
- IF conn.errors.count> 0 then
- response.write "Database Errors Occured" & "<P>"
- response.write SQLstmt & "<P>"
- for counter= 0 to conn.errors.count
- response.write "Error #" & conn.errors(counter).number & "<P>"
- response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
- next
- else
- response.write "<br><br><font face='arial' size=4><b>"
- response.write "Thank you! Your entry has been added.</font><p>"
- response.write "<font face='arial' size=2>"
- response.write "<a href='default.asp'>View Guestbook</a>"
- 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 = "info@web-savant.com" ' put your email address here
- Else
- Sender = request("email")
- End If
- Mail.From = Sender
- Mail.To = "you@yourdomain.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 & "URL: " & URL & Chr(10)
- Msg = Msg & "Comments:" & Chr(10)
- Msg = Msg & request("Comments")
- Mail.Body = Msg
- Mail.Send
- Set Mail = Nothing
-
- End If
- %>
- </center>
- </body>
- </html>