|
/ Home
/ Guest Book
|
<%
if (Request("action") == "add_entry"){ //add an entry to the guestbook
guest_show = "True";
var guest_name = String(Request("guestname"));
guest_name = guest_name.replace(/'/g,"'"); //Replace all the ' with HTML code
var guest_comment = String(Request("guestcomment"));
guest_comment = guest_comment.replace(/'/g,"'");
var guest_date = String(Request("guestdate"));
guest_date = guest_date.replace(/'/g,"'");
sql_insert = "INSERT into guest_table (guest_name, guest_comment, guest_date, guest_show) values ('" + guest_name + "', '" + guest_comment + "', '" + guest_date + "', " + guest_show + ")";
//Response.Write(sql_insert);
Conn.Execute(sql_insert);
%> Thanks for submitting your comments.
<% = guest_comment %>
View the Guest Book
<%
}
else if (Request("action") == "write_entry"){ //Show a form so user can add an entry to the guestbook
var now = new Date ();
var myday = now.getDate();
var mymonth = now.getMonth() + 1;
if (mymonth < 10){mymonth = "0" + mymonth}
var myyear = now.getYear();
var dateString = myday + "/" + mymonth + "/" + myyear;
%> What do you think? Everyone wants to know, so tell us and them by filling
in the form!
View the Guest Book
<%
}
else { //nothing else to do, so display the guestbook
%>Before you add your comments,
why not peruse what others have written.<%
sql = "SELECT * FROM guest_table WHERE guest_show=True ORDER by guest_date DESC"
rs = Server.CreateObject("ADODB.RecordSet");
rs.Open (sql, Conn, 2,3);
if (rs.EOF){
Response.Write("No comments found...submit the first! ");
}
else{
tips_array = new Array ();
i = 0;
while (! rs.EOF){
%>
Name : <% = String(rs.Fields.item("guest_name")) %>
(<% = rs.Fields.item("guest_date") %>)
Comments : <% = rs.Fields.item("guest_comment") %>
<%
rs.Move(1);
i ++
} //end while
} //close else
rs.Close ();
%>Now you've seen them, add your own comments. <%
}
%> |
|
|
|
|